Controling a href

Controling a href, a forum discussion on Jojo CMS. Join us for more discussions on Controling a href on our General Discussion forum.

Back to Forum Index : Back to General Discussion   RSS
Jaijaz Jaijaz

18 May 2009
Posts: 215

OK so I feel like I should know this one but I just can't seem to work it out.

In a tpl file I am building a href link that should look like #tab-1 for example. That part is simple. However when the page loads it is putting in: products/#tab-1/ which would be a problem except that it is killing my jQuery UI tabs.

Does anyone know if there is smarty of Jojo putting in the plugin uri into the href and if there is anyway to stop it?

Jai
If you not living on the edge you taking up too much space.
Harvey

Core Developer

Harvey

18 May 2009
Posts: 327

Hi Jai,

Jojo uses the base href tag in the HTML. So in a normal page, if you were to on domain.com/products/ and linked to #foo then you would find that clicking the link would take you to domain.com/#foo which isn't what you want. So Jojo has some code which parses your page for # links and prepends the current REQUEST_URI, so that clicking the link takes you to domain.com/products/#foo which is what you want.

OK, so this functionality is killing your tabs. I have 2 suggestions.

Firstly, you can add some javascript to undo the change that Jojo made to these links. Just use the JS code on the product page and not sitewide. Use a selector like $('#content a') or $('a.whatever_class_tabs_use') and regex out anything before the # on those link href attributes.

The other way is to prevent Jojo from 'fixing' the links in the first place. From memory, this is in jojo_core.php - this will involve hacking the core, though I don't see why an option couldn't be added to make this behaviour optional.

Harvey.
Jaijaz Jaijaz

18 May 2009
Posts: 215

Thanks Harvey.

I figured that was why it was happening. To be honest on multi language sites it is very useful.

I was thinking option 1 is best as then it degrades nicely for those 2% with javascript turned off.

Thanks again.
If you not living on the edge you taking up too much space.
Jaijaz Jaijaz

8 Jun 2009
Posts: 215

Finally got time to get back to this one. In case anyone is interested here is the code I used, placed after the tab elements in the tlp file. First time I've ahd to use a loop in javascript. It is obviously using jQuery.

$(function() {
var n = $("ul.productcats li a").length;
for (var i = 0; i < n; i++)
{
var subject = $("ul.productcats li a:eq("+i+")").attr("href");
var myregexp = /(?:.*)(#.*)/;
var match = myregexp.exec(subject);
$("ul.productcats li a:eq("+i+")").attr("href", match[1]);
}
});
If you not living on the edge you taking up too much space.
Back to Forum Index : Back to General Discussion   RSS
You must be logged in to post a reply



You need to Register or Log In before posting on these forums.