View Full Version : categories with section names
trichnosis
09-16-2006, 05:39 PM
hi
i installed jasubmit 2,1 but it show only category name. i want to show category names and section names in the submit form like section_name>category_name. is that possible to do?
thanks
iwindsurf
10-23-2006, 11:15 AM
I also found this a slight restriction in an otherwise great component.
It would be great to include sections rather than categories or somehow both, even at admin level but I see that is inthe wishlist many times.
to answer your questionas a dirty fix I altered the code in admin.ja_submit.php approx lines 133 onwards to
$query = "SELECT cat.id, cat.name, cat.section, sec.name, CONCAT(sec.name,'->',cat.name) AS display_name"
. "\n FROM #__categories as cat RIGHT JOIN jos_sections as sec ON cat.section = sec.id"
. "\n ORDER BY cat.ordering"
;
$database->setQuery( $query );
$categories = $database->loadObjectList() ;
//Select selected categories
$listId=array();
$listId=explode(",",$H_avaiCategories) ;
foreach ($listId As $key)
{
$keyObject=new stdClass();
$keyObject->id=$key;
$listKeys[]=$keyObject;
}
$lists['catid'] = mosHTML::selectList( $categories, 'listcatid[]', 'class="inputbox" size="8" multiple="multiple"', 'id', 'display_name',$listKeys );
?>
the main change is the sql query which joins the section table and gets the name - the right join means you only get catagories where the query finds a section name
The query creates a new field "display_name" which is then passed to mosHTML::selectList - that's the other change
this only changes what you see in the admin config page - to change it in the new/edit page you need to edit file components->com_ja_submit->ja_submit.html.php
around line 155 you'll find
$database->setQuery( "SELECT * FROM #__categories");
change this to
$database->setQuery( "SELECT cat.id, cat.name, cat.section, sec.name, CONCAT(sec.name,'->',cat.name) AS display_name
FROM jos_categories as cat RIGHT JOIN jos_sections as sec ON cat.section = sec.id");
then below that you'll see a for each loop with
echo $row->name;
change this to
echo $row->display_name
you now get section->catagory in all your lists :cool:
I've tested this BRIEFLY - let me know if there are problems :eek:
trichnosis
10-23-2006, 05:35 PM
wonderfull . it's working now:)
iwindsurf
10-24-2006, 07:09 AM
You might change the table names to #__ instead of jos_ as you might not have used jos_ ?
I'm currently working on adding section control above the category control - will post here a link to files if people wish.
isitmeor
10-24-2006, 10:18 PM
You might change the table names to #__ instead of jos_ as you might not have used jos_ ?
I'm currently working on adding section control above the category control - will post here a link to files if people wish.
can je please pm me the changed files?
TIA
ekajatik
11-14-2006, 03:48 PM
How's progress? Looking forward to this as I have over 60 categories in 5 sections...
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.