Generating Component SEF URLs in Joomla - php

I have a custom Joomla component and a router for building my SEF URL's for use within the site, and everything is usually shiny - internally, all of my links look and act fantastic.
I recently route a controller action that sends a list of links through email, and I've noticed that my URLs are coming out.... funky - hopefully someone can tell me why.
Usually, my router generates an internal link that looks like this:
http://localhost/Registry/calendar/265889635/Some-Long-Boring-Event
However, when I send an email and preparing the same URL through the same router I get:
http://localhost/Registry/Registry/component/calendar/569555803/Some-Long-Boring-Event
Has anybody run into this issue before?

Check your Itemid GET parameter in the URL. My guess is that it's not set in the url used in emails...

I would turn off SEF URLs temporarily and get the non-SEF version of the link you want. Compare that will the URL you are using and see what is different/missing.

Related

Redirect a URL with /#/

Our current website is built using AngularJS and as a result has URLs with /#/in them such as http://www.website.com/#/termsofuse
Short-sightedly, the URL for terms or use has been hard coded into a mobile application and although this has been changed, some users still have older versions.
We're moving to a WordPress site (running on Azure) and the new URL for terms of use is http://www.website.com/termsofuse
The issue is that I want to redirect to the new URL if the old URL is used (from the app where it is hard coded in older versions) but I can't find a way to do this with the /#/ in the URL (otherwise I could use HTML/JS at the old URL to redirect).
I have tried searching for solutions on Google and here but although I'm sure someone has had this problem, I'm finding it hard to define the search terms in order to get valuable results.
I also considered posting this on WordPress stackexchange but it is not really a WordPress question, I'm assuming I'll need to use some other method.
Appreciate any ideas or advice. Thanks in advance.
So far I have learnt from responses that I probably need a JS solution and based on that I have found the below which looks similar (at least shows me how to isolate the fragment after the URL). Since my issue is very specific, and I only need to look for the specific fragment #/termsofuse could I use this code (with midifications) to look for that string and redirect based on that?
Checking URL fragment for a keyword
Sadly, this is not possible as everything after the # doesn't get sent to the server.
What many people do in this sort of situation is to use a javascript/ajax solution to load the page.
By your description, as your new web site is built on WordPress without AngularJs.
So it hardly could approach your need in a traditional way. As hashtag # is a client symbol which is never passed on serve, so IIS on Azure will not get the portion after # of the URL, also URL rewrite module won’t see it too.
So if possible to modify home page of your WordPress site, here is a workaround with using JavaScript get the portion after # of the URL and redirect to the right URL.
Here is the code snippet:
(function () {
console.log(window.location.href);
var url = window.location.href;
params = url.split('#');
console.log(params);
if(params[1]){
window.location.href = params[1];
}
})();

ExpressionEngine custom url routing

From what I understand, Expression Engine url parsing works like this:
site/template/
I want to deeplink straight off the regular site url, like this:
site/special-deep-link
and I have javascript in place to carry out specific actions.
But EE is just assuming this is a template, and giving me a 404 saying it does not exist (which is true). So naturally the js does not fire and nothing works.
Is there any way to stop EE from trying to parse it as a template without using .htaccess or other server side config settings?
Unfortunately the old codeigniter way of rule routing doesn't seem to be working.
I tried:
$route['site/special-deep-link'] ='';
$route['/special-deep-link'] ='';
$route['index/special-deep-link'] ='';
But sadly none of those seem to work. Any thoughts on this?
Figured it out, using this plugin:
http://devot-ee.com/add-ons/freebie
I was able to have EE ignore that url string.

Joomla component + friendly url

I'm new at Joomla. I just had made my first component and module. I use _GET parameters such as 'page', 'nr' and 'q' (q contains _POST parameters in base64) because I made my own pagination. So, when I try to use it on Joomla it works fine and the url without SEF looks like this:
http://mydomain/?option=com_mycomponent&view=test&page=0&q=[base64]
But what I want is to make it friendly. I think it should something like this:
http://mydomain/component/mycomponent/view/test/page/0/q/[base64]
I enabled SEF in joomla and when I print JRequest::get('get') it just appear option and itemid parameters. What should I do to get the rest of them?
Thanks in advance.
You should define routing in your component. That should give joomla what it needs to output what you're requesting. http://docs.joomla.org/Supporting_SEF_URLs_in_your_component
There are also other SEF plugins that attempt to do this across your whole Joomla site, but they don't always work 100%.

How to make a correct Joomla URL using the Joomla Classes

I am busy making a Joomla! component. And know i want to link to another component. So, as example i want to link from my component 'my_component' to 'his_component'. Normally this is simple to do. Just make a normal link like href="?option=com_his_component". But the problem is that one of my consumers uses SEO friendly URLs. And in that case this URL won't work.
Does anyone know a way to this the correct way (I think with the Joomla! Api)
Just wrap that link with a call to JRoute::_($url):
$link = JRoute::_('index.php?option=com_his_component&foo=bar');

joomla fully customize component link

I made a component and now I want to customize the link for it.
I already wrote the router.php.
The link to the component view (if I use the JRoute function of course) now looks good, except for the first part, which looks like :
http://www.example.com/en/component/componentname/...
don't mind the "en", it's there cause I use JomFish to manage more languages on my site.
I want to transform "/component/componentname/" to "/myString/" for example.
I can't use the menu for this, cause my site displays info from a database, linking this many sites to my menu is impossible.
The only solution I found requires the changing of the Joomla JRoute function (I found only a suggestion, not how it's done :( ).
What about using mod_rewrite to rewrite your url?
Basically you put the rewrite rules into your .htaccess file and Apache will handle the rest.
There is a great guide that teaches you all about it on http://www.htmlist.com/how-to/a-simplemod_rewrite-tutorial/

Categories