Topic: Diferent menus, based on content category?
Converted
avatar
12
Posts: 0

Posted:
5.Jun 2008 - 07:23

I have a question, is there a way to have for example four menu blocks, and every one display only when dokument from specified category is displayed. Or something similar.. In pagesetter I can do this, because there is diferent publication type - Theme settings->Page configurations assignments->different ini file , but in Content Isn't pub. types.
Converted
avatar
12
Posts: 0

Posted:
11.Jun 2008 - 07:10

Hello sorry for my english :-D
I have done little changes in Content/pnuserapi.php :

Code

if (substr($lastarg, strlen($lastarg)-strlen($suffix)) == $suffix) {

for ($i=2; $i<$argsnum; $i++) {

if (!empty($urlname))

$urlname .= '/';

$urlname .= $args['vars'][$i];

}

$urlname = substr($urlname, 0, -strlen($suffix));



$pageId = pnModAPIFunc('content', 'page', 'solveURLPath', array('urlname' => $urlname));//new

$category = pnModAPIFunc('content', 'page', 'GetPageCategory', $pageId);//new



pnQueryStringSetVar('func', 'view');

pnQueryStringSetVar('name', $urlname);

pnQueryStringSetVar('pid', $pageId);//new

pnQueryStringSetVar('cat', $category);//new

return true;

}

lines commented //new are new or modified

and I created new fuction in Content/pnpageapi.php:

Code

function content_pageapi_GetPageCategory($pageId) //new

{

$pntable = pnDBGetTables();

$pageTable = $pntable['content_page'];

$pageColumn = $pntable['content_page_column'];

$pageId = (int)$pageId;



$sql = "

SELECT $pageColumn[categoryId]

FROM $pageTable

WHERE $pageColumn[id] = $pageId";



$dbresult = DBUtil::executeSQL($sql);



if ($result->EOF)

return false;



$category = '';

for (; !$dbresult->EOF; $dbresult->MoveNext())

{

$category = (int)$dbresult->fields[0];

}



$dbresult->Close();



return $category;



}


now is possible to use advanced block placement option in Block settings to distinguish which blocks will be displayed, based on content category or pid! On advanced block placement page, is neccesery to set function type=user, function=view and custom arguments: cat=xx or pid=xx. For example is possible to use more arguments: pid=1, pid=3, cat=5 etc.. And the block will display only if the dokument is in specified category or only for specified dokument 8-)
This modification works only with short urls enabled!



edited by: antz, Jun 11, 2008 - 08:13 AM
Converted
avatar
12
Posts: 0

Posted:
11.Jun 2008 - 18:04

Actually, you could do this using the Extended Menu block in PN 0.8 RC4 / Zikula 1.0. You can assign certain menu items to specific pages within your site. For an example of what I mean and how I used it, visit http://www.pdgroupllc.com -- take note of the menu then click on "Services" and you'll see new menu items appear.
Converted
avatar
12
Posts: 0

Posted:
11.Jun 2008 - 22:01

Wendell

Actually, you could do this using the Extended Menu block in PN 0.8 RC4 / Zikula 1.0. You can assign certain menu items to specific pages within your site. For an example of what I mean and how I used it, visit http://www.pdgroupllc.com -- take note of the menu then click on "Services" and you'll see new menu items appear.


Yes, It works, but only with short URLs disabled, because with short URLs enabled the returned argument is only content item name (not pid). The modification above, is the solution to do this with short URLs enabled.