Multi-language data

Multi-language data, a forum discussion on Jojo CMS. Join us for more discussions on Multi-language data on our General Discussion forum.

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

14 May 2011
Posts: 215

Had an interesting thought and would like feedback as to whether it is a good idea or not.

I occurred to me that the number of plugins that call Jojo::getMultiLanguageData() is starting to grow. Looking at the code for the function is looks like there is a database query each time it is called.

In the vain of trying to minimise database queries is it worth defining a global, say $_MULTILANGDATA in the includes/jojo.php file when it is called there.

And/or is adding a cache to the function better?
If you not living on the edge you taking up too much space.
tom

Developer

tom

15 May 2011
Posts: 379

As far as I know the mldata function does cache the result, so it should only be calling the database once and use the cached copy for every subsequent request.

Core global.php also generates a bunch of useful variables from it, which can also be referenced rather than calling the function directly

$root = Jojo::getSectionRoot($page->id);
$selectedPages = Jojo::getSelectedPages($page->id, $root);
$smarty->assign('selectedpages', $selectedPages);
$smarty->assign('pageurlprefix', Jojo::getPageUrlPrefix($page->id));

$mldata = Jojo::getMultiLanguageData();
$sectiondata = isset($mldata['sectiondata'][$root]) ? $mldata['sectiondata'][$root] : '';
$smarty->assign('home', ($sectiondata ? $sectiondata['home'] : 1));
$smarty->assign('root', $root);
tom

Developer

tom

15 May 2011
Posts: 379

other mldata functions that you can use for more specific purposes:

getPageUrlPrefix($pageid) returns the url prefix (if any) for multi-language/subsite sites, but is safe to use on single instance ones also. This is designed to replace the problematically named and slightly wonky getMultiLanguageString function.

getSectionRoot($pageid) will tell you which sub-site section a particular page is in (and consequently which mldata to use, whether to include/exclude it from results and so on)
Jaijaz Jaijaz

19 May 2011
Posts: 215

Thanks Tom. I'd forgotten to look at global.php

The thing I'm doing is using $mldata['sectiondata'] as a dynamic list of site sections to create a global navigation across the site. I can't see this variable set anywhere. Also $mldata['sectiondata'] isn't ordered by display order so I'm doing a sort on it.

Would this be useful to anyone else?
If you not living on the edge you taking up too much space.
tom

Developer

tom

19 May 2011
Posts: 379

I actually had the displayorder change there already.. have committed it.
you so you should be able to use
$smarty->assign('languagelist', $mldata['sectiondata']);
for ordered navigation

The name is wrong of course because its a lang/country list not a lang list, but it's there for backwards compatibility with a screed of multi-language sites we have that use that variable for a drop-down navigation list
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.