I´m trying to transform my Url according to Magnolia documentation:
https://documentation.magnolia-cms.com/display/DOCS/URI+mapping#URImapping-URItorepositorymapping
I need to change my language page:
I receive this:
http://localhost:8080/module/en/TEST_/newsdetails/201602151
With this sentence:
<a href="${cpathx}/${cmsfn.language()}/${rootPage}/newsdetails/${encodeTitle!""}">
And I´m transforming by UriMapping to this:
http://localhost:8080/module/en/TEST_/newsdetails?newsRef=201602151
I don´t know when i do the URIMapping it doesn´t show in my language 'EN', only shows the language by default and doesn´t get the 'EN'
This´s my URIMapping:
and this is my site definition config:
The problem is when i do:
${cmsfn.language()}
It returns my language by default..
Also I,ve tried putting this URiMapping:
You need locale aware VirtualURIMapping - see Matteo Pelucco's blog post: http://maips21.altervista.org/wordpress/2015/05/05/how-to-build-a-locale-aware-virtualurimapping-in-magnolia-with-regexp/
Related
I need to create a hyperlink using XDocReport where both the URL and display name are provided using Velocity tags. There is some reference to this on the XDocReport web site, but no real guidance.
Other things I have tried, like http://blog.softartisans.com/2013/12/31/kb-creating-dynamic-links-with-mergefields-in-microsoft-word/, do not work.
Manage hyperlink with XDocReport is like mergefield. XDocReport wiki page about hyperlink with docx can be found here, but I agree, it should be improved.
If you cannot manage hyperlink with XDocReport and docx, I suggest :
use the XDocReport macro . There is a link checkbox to insert hyperlink instead of inserting mergefield.
download docxandvelocity-XXX-sample.zip or get Git project fr.opensagres.xdocreport.samples.docxandvelocity. You will find samples with hyperlinks.
Based on #MarkSalamon suggested link: http://blog.softartisans.com/2013/12/31/kb-creating-dynamic-links-with-mergefields-in-microsoft-word/ , it failed in my case too.
After debugging the opensagres library, it seems that instead of inserting a merge field inside the Hyperlink, the library is expecting there just a simple Freemarker placeholder. So it's enough to create the hyperlink from Word, and at the url definition part, you can specify there: ${url} .
That's it, the library is going to detect that there is a Freemarker syntax and replace the url with back-end data. So you don't have to do the trick with ALT+F9 and replace with merge field codes.
In my case this worked with opensagres version: 2.0.2
Working in ZF: Is it possible to change the base or root url on the www.example.com to www.example.com/$language/home, thus depending on the (browser) locale of the users browser?
Example; If a guest manually types www.example.com I would like to change the url automatically to a url with locale: www.example.com/en/home for guests in en_GB region or www.example.fr/home for guests in fr_FR region.
From the root-url I have all the menu-urls and content locale aware. Clicking a link to a menu item in the url the lang is automatically added after the root. The content on the root url is locale aware too using translate, so english for en_GB en french for fr_FR, etc.
Still missing though I would like to have the root url change to locale aware right from the start of the visit to the application if only the root is entered.
I guess something like
root :to => redirect("/prepayments")
in Rails 3 from what I understand from this Q&A on this forum
I have tried and implemented controller action helpers, redirects, etc. etc. for as far as I could find on this forum, but they all don't offer the solution.
A redirect in htaccess is not possible I think since I first need to get the locale from the browser. Since I don't know this the redirect is dynamic and I cannot set a redirect in htaccess.
I woud appreciate any suggestions?
Since I don't know what version of Zend you're using I am posting this for Zend 1.1x. One thing you could do is "catch" the request before it is dispatched, get the Accept-Language header and based on the user's preferences there set the locale or redirect the user to a URL you like. One way to do this is in the FrontController's preDispatch() method.
Keep in mind that:
You will need to check if all browsers send this through
This header string must be parsed careful
Because of the way it is defined:
Accept-Language en,bg;q=0.7,en-us;q=0.3
Also users may and often do set language preferences to a foreign language so this header on its own may not be enough.
The best way to do this in a OOP way is to wrap this functionality in a ZendPlugin.
Attach it in your bootstrap:
protected function _initLocaleHandlerControllerPlugin() {
$frontController = Zend_Controller_Front::getInstance();
$plugin = new App_Controller_Plugin_LocaleHandler();
$frontController->registerPlugin($plugin);
}
Now in this plugin redefine the preDispatch() callback:
public function preDispatch(Zend_Controller_Request_Http $request) {
$acceptLang = $request->getHeader('Accept-Language');
//Parse string and get language
//After parsing set the appropriate locale in `Zend_Locale`
//redirect the user/dispatch the request?
//THIS IS JUST AN EXAMPLE:
$request->setModuleName('home')
->setControllerName('registration')
->setDispatched(true);
}
Zend 1.x doesn't seem to have a built in class for this, Zend 2 does have the "Zend\Http\Header\AcceptLanguage" class.
I finally found the next solution on my question with a little help from Florent in Zend Framework: Redirect from action helper:
In my Language Plugin I added
public function routeShutdown(Zend_Controller_Request_Abstract $request)
{...some code handling translate...
$url = $request->getRequestUri();
if ($url === '/') {
$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
$redirector->gotoUrl($lang.'/home');
}
The routes I have them in a routes.ini so $lang.'/home' is routed to the indexController and indexAction of the Default module.
I was hoping someone might be able to give me some help with what I am planning to do...
I want to create a dynamic "City.aspx" page that accepts a url parameter and dynamically generates a page based on that particular city.
For example, if someone called "City.aspx?city=london" then it would build a page with custom content relating to London and if someone called the page "City.aspx?city=manchester" it would build the page with content relating to Manchester.
I have looked into building the sitemap and UrlRewriting and am pretty sure i can redirect to this new page with a parameter but have no idea what I need to do next.
Can anyone help please?
Thanks
TaxiRoute
I would recommend that you create url's like /city/london/1234 where the last part is the ID of your document.
By using the built-in UrlRewrite function in Umbraco, you can make the url be internally rewritten to /city.aspx?name=london&id=1234
In the /config/Urlewriting.config you can add rewrite rules.
For the above you need something like this:
<add name="city_rewrite"
virtualUrl="^~/city/(.*)/(.*)"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/city.aspx?name=$1&cityid=$2"
ignoreCase="true" />
Once you have this sorted out, you can use the following code in your code-behind off the City.aspx Macro to get the corresponding Document.
// get the city Document Id from the querystring
string cityID = HttpContext.Current.Request.QueryString["cityid"];
if (!string.IsNullOrWhiteSpace(cityId))
{
// get the cityNode
Node cityNode = new Node(cityId);
// do whatever you want with this node, like display it's data
}
This is a .NET Macro, but of course you can do the same with XSLT or Razor-code.
If you have the information outside of standard Umbraco content that is dynamic for each city, then simply write a macro or macros (or partial views?) to get the dynamic data via that "city" get parameter. Then you can use UrlRewriting to make URLs look like standard web pages (/city/london.aspx). UrlRewriting will make that URL appear to the server as though it was this: /city.aspx?city=london. (http://our.umbraco.org/wiki/reference/packaging/package-actions/community-made-package-actions/add-an-url-rewrite-rule)
In your macros you can either pass the "city" get parameter to the macro(s) as a macro parameter via bracket syntax (http://our.umbraco.org/wiki/reference/templates/umbracomacro-element/macro-parameters/advanced-macro-parameter-syntax). Or your can just get the city parameter via request variables (razor) or Umbraco.library (XSLT).
I know that to localize the regular (JavaScript) reCAPTCHA I can provide lang attribute to Recaptcha.create method as specified in documentation I've tried to do the same for noscript version by passing lang in query string like this http://www.google.com/recaptcha/api/noscript?k=<key>&lang=ru, but I still got an English version.
Does anyone know how to localize the iframe version?
try using &hl=ru parameter. hope this help.
I have a news section where the pages resolve to urls like
newsArticle.php?id=210
What I would like to do is use the title from the database to create seo friendly titles like
newsArticle/joe-goes-to-town
Any ideas how I can achieve this?
Thanks,
R.
I suggest you actually include the ID in the URL, before the title part, and ignore the title itself when routing. So your URL might become
/news/210/joe-goes-to-town
That's exactly what Stack Overflow does, and it works well. It means that the title can change without links breaking.
Obviously the exact details will depend on what platform you're using - you haven't specified - but the basic steps will be:
When generating a link, take the article title and convert it into something URL-friendly; you probably want to remove all punctuation, and you should consider accented characters etc. Bear in mind that the title won't need to be unique, because you've got the ID as well
When handling a request to anything starting with /news, take the next part of the path, parse it as an integer and load the appropriate article.
Assuming you are using PHP and can alter your source code (this is quite mandatory to get the article's title), I'd do the following:
First, you'll need to have a function (or maybe a method in an object-oriented architecture) to generate the URLs for you in your code. You'd supply the function with the article object or the article ID and it returns the friendly URL with the ID and the friendly title.
Basically function url(Article $article) => URL.
You will also need some URL rewriting rules to remove the PHP script from the URL. For Apache, refer to the mod_rewrite documentation for details (RewriteEngine, RewriteRule, RewriteCond).