Log in | Register | Lost password

Bottom
Tree-like Category/Article listing
  • Posted: 07.09.2005, 19:06
     
    Converted
    rank:
    12
    registered:
     March 2009
    Status:
    offline
    last visit:
    Posts:
    0
    My php knowledge is way too limited to get this done it seems, I'm fiddling since days and don't get it. Maybe one of you can help me.
    What I try to do is getting the list of some library like thing basing at the knowledge base templates showing three colums:
    categories - subcategories of the category when choosen - articles of the category and subcategory

    You can see what I got so far here:
    http://valhyre.com/upgrade/index.php?module=pagesetter&tid=6&orderby=core.created:desc

    It shows the articles fine of the choosen category but I don't get the changed listbrowser plugin I used for the subcategory listing to show only the subcategories of the main category I clicked at.
    So far listbrowser seems to totally ignore every filtering. So my basic question is: how do I get filtering in for listbrowser plugin so I can pull the cv from the url in address bar or how do list categories as I list publications with inlinePublist that takes filtering?

    Edit: basically I just need to get the $item parentid from the db and compare it with $currentValue - but how I get in the rec function what parentid the $item[id] has?

    Edit2: lol - ok putting it written down like that triggered the understanding.
    My subcategory-lister looks like that now:

    Code

    <?php



    // Thanks to Joerg Napp for some serious bugfixes in this plugin.



    function smarty_function_pagesetter_listScat($args, &$smarty)

    {

    //$smarty->caching = 0; // Nice for debugging ...



    if (!isset($args['field']))

    return "Missing 'field' argument in Smarty plugin 'pagesetter_listScat'";



    $field = $args['field'];

    $listClass = $args['listClass'];

    $level = (empty($args['level']) ? 1000 : $args['level']);

    $topValue = $args['topValue'];

    $currentValue = (isset($args['currentValue']) ? $args['currentValue'] : pnVarCleanFromInput('cv'));

    $template = $args['tpl'];



    if (isset($args['tid']))

    {

    $tid = $args['tid'];

    }

    else

    {

    $core = $smarty->get_template_vars('core');

    $tid = $core['tid'];

    }





    if (!pnModAPILoad('pagesetter', 'admin'))

    return pagesetterErrorPage(__FILE__, __LINE__, 'Failed to load Pagesetter admin API');



    $listID = pnModAPIFunc( 'pagesetter',

    'admin',

    'getListIDByFieldName',

    array('tid' => $tid,

    'field' => $field) );



    if ($listID === false)

    return pagesetterErrorAPIGet();



    $listInfo = pnModAPIFunc( 'pagesetter',

    'admin',

    'getList',

    array('lid' => $listID,

    'topListValueID' => $topValue) );



    if ($listInfo === false)

    return pagesetterErrorAPIGet();



    // build the parameters for the URL.

    // these are the same for every item.

    $url_parameters = array();

    $url_parameters['tid'] = $tid;

    if (!empty($template)) {

    $url_parameters['tpl'] = $template;

    }



    $items = $listInfo['items'];

    $indent = $items[0]['indent'];



    $i = 0;

    $setup = array('currentValue' => $currentValue,

    'listClass' => $listClass,

    'field' => $field);

    $html = pagesetter_listScat_rec($items, $i, $indent, count($items), $url_parameters, $setup);



    return $html;

    }







    function pagesetter_listScat_rec(&$items, &$i, $indent, $size, &$url_parameters, &$setup)

    {

    if (isset($setup['listClass']) && $i == 0)

    $html = "\n";

    else

    $html = "\n";





    while ($i < $size)

    {

    $item = $items[$i];



    if ($item['indent'] < $indent)

    break;



    $url_parameters['filter'] = "$setup[field]^sub^$item[id]";

    $url_parameters['cv'] = $item['id'] ;

    $parent = $item['parentID'] ;

    $current = $setup['currentValue'];

    echo $parent;



    $url = pnModUrl('pagesetter', 'user', '', $url_parameters);



    if ( ($indent != "0") && ($current == $parent)) //its a sub-category

    $html .= "<tr><td width=20px>&nbsp;</td><td><a href=\"$url"."&orderby=title\">- $item[title]</a></td></tr>\n";



    ++$i;



    if ($items[$i]['indent'] > $indent)

    {

    $html .= pagesetter_listScat_rec($items, $i, $indent+1, $size, $url_parameters, $setup);

    }



    $html .= "\n";

    }



    $html .= "\n";



    return $html;

    }





    ?>


    My list header looks like this:

    Code

    <div class="pn-title" align="center">Library</div>

    <br>

    <table width="100%">

    <tr>



    <td width=30% valign="top" align="left" class="pn-title">



    <table valign="top">

    <tr><td colspan="2" class="pn-title">Categories<br><br></td></tr>

    <!--[pagesetter_listBrowser field="category"]-->

    </table></td>



    <td width=30% valign="top" align="left" class="pn-title">

    <table valign="top">

    <tr><td colspan="2" class="pn-title">Subcategories<br><br></td></tr>

    <!--[pagesetter_listScat field="category"]-->

    </table></td>

    <!--[ pnvarcleanfrominput name=cv assign=cv ]-->

    <!--[pagesetter_createFilter filter="category:eq:`$cv`" assign=listFilter]-->

    <td width=30% valign="top">

    <div class="pn-title" >Articles<br></div>

    <br>

    <!--[pagesetter_inlinePubList tid=6 filter=$listFilter orderby=title pubcnt=400]-->

    <br />




    edited by: Horian, Sep 07, 2005 - 10:45 PM

Template courtesy of Designs By Darren.