jDiction Forum
English => General Questions => Topic started by: zigzo on September 27, 2013, 11:11:57 am
-
Hello,
I am using jDiction and Phoca Gallery and with the jdiction.xml in another thread I could translate the category names successfully. Thanks!
However, I got a problem when trying to write some codes to select categories from the category table. When I use select title from the category table, it can only retrieve the original names.
How can I get the translated titles according to my site language? Do I need to refer to the jdiction sql table in my code as well? Thanks!
-
No this is not needed, jdiction intercept your query and adds the table key to the select list. After this it translates it on the fly.
You should use jdatabasequery so this could work without problems.
show me your sql query + php code
-
Hi, thanks for your reply.
Actually I'm using chronoforms to generate the DB query to select the id, title...etc. from _phocagallery_categories. The title is translated using jdiction.
I have attached the related php code.
Thanks for helping!!
-
Hmm is a bit hard to say... maybe its better you show me the db query. Use the joomla debugmode to show all queries.
-
The query is like this:
SELECT `id`, `owner_id`, `title`, `userfolder`, `latitude`, `longitude`
FROM `cwosjm_phocagallery_categories` AS `myCategory`
WHERE owner_id = 852
And then I refer to the 'title' field to display in dropdown box.
-
is this query from the debug view?
because jdiction didn't touched this query.
So its possible that it was unable to parse it.
could you try to execute the query by hand?
just copy this code to the index.php in the template folder
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select("id, owner_id, title, userfolder, latitude, longitude");
$query->from("#__phocagallery_categories AS myCategory");
$query->where("owner_id = 852");
$db->setQuery($query);
$x = $db->loadObjectList();
print_r($x);
this should be translated.
if this doesn't work then there is a bigger problem with the jdiction installation.
after that please the ` to all fields like in your query and try again.
if this sill works, use this code:
$db = JFactory::getDbo();
$query = "SELECT `id`, `owner_id`, `title`, `userfolder`, `latitude`, `longitude` FROM `cwosjm_phocagallery_categories` AS `myCategory` WHERE owner_id = 852";
$db->setQuery($query);
$x = $db->loadObjectList();
print_r($x);
If this sill work then chronoforms does some unnice query string that couldn't be parsed by jdicion.
-
Thanks for your reply!
The 1st one works. And when I added ` for all fields, it works too.
The 1-line query code doesn't work though.
-
to things I made an error at
"FROM `cwosjm_phocagallery_categories` AS `myCategory`"
this should be
"FROM `#__phocagallery_categories` AS `myCategory`"
also try this query without `
-
All of them work. So it must be some manipulation inside the chronoforms...
I have just tried your code for the sql query instead of the default chronoform action and it works now~
Thanks for your help!
-
If you can life with it take the first version for performance reasons
-
I see. Thanks a lot!!