Fork me on GitHub

Template logic was working, now isnt.  Bottom

Go to page [-1] 1 - 2:

  • LOL, duh. Woops, thanks. Got any ideas about what i need to do to have more control over the category placement?
  • What's the structure of the array?

    -Mark

    --
    Visit My homepage and Zikula themes.
  • Not exactly sure if this is what your looking for.

    Code

    /**
     * Get categories
     *
     * This user api function builds a list of the available categories.
     *
     * @param       void
     * @return      array                       This is an array of the available
     *                                          categories.
     */

    function pxPDFManager_userapi_getcategories($args) {
        // Create a container array for the categories.
        $categories = array();
         
        // Security check - important to do this as early on as possible to
        // avoid potential security holes or just too much wasted processing.
        if (!pnSecAuthAction(0, 'pxPDFManager::', '::', ACCESS_READ)) {
            return $link_listing;
        }
       
        // Check to see if we should see the private or public
        // categories.
        if (! isset($args['private'])) {
            $args['private'] = 0;  
        }
       
        // Get datbase setup - note that both pnDBGetConn() and pnDBGetTables()
        // return arrays but we handle them differently.  For pnDBGetConn() we
        // currently just want the first item, which is the official database
        // handle.  For pnDBGetTables() we want to keep the entire tables array
        // together for easy reference later on.
        $dbconn     =& pnDBGetConn(true);
        $pntables   =& pnDBGetTables();
       
        // It's good practice to name the table and column definitions you are
        // getting - $table and $column don't cut it in more complex modules
        $pdf_categories_table   = $pntables['pdf_categories'];
        $pdf_categories_column  = &$pntables['pdf_categories_column'];
       
        // Build the sql query to select a list of the categories.
        $categories_sql = "
            SELECT $pdf_categories_column[category_id],
                   $pdf_categories_column[category_name]
            FROM $pdf_categories_table
            WHERE $pdf_categories_column[private] = '"
    . $args['private'] ."';
        "
    ;

        // Execute the categories query and return the result set.
        $result =& $dbconn->Execute($categories_sql);
       
        // Check for an error with the database code, and if so set an appropriate
        // error message and return.
        if ($dbconn->ErrorNo() != 0) {
            pnSessionSetVar('errormsg', __ERROR_PXPDFMANAGER_GETCATEGORIESFAILED);
            return false;
        }
       
        // Loop through the result set.
        for (; !$result->EOF; $result->MoveNext()) {
            // For each "node" in the result set list the
            // category_id and category_name fields.
            list($category_id, $category_name) = $result->fields;
           
            // Add this category to the categories container.
            $categories[] = array('category_id' => $category_id,
                                  'category_name' => $category_name);
        }
       
        // Close the result set.
        $result->Close();
       
        // Return the categories array.
        return $categories;
    }
  • Just an array dump would have been ok.... So the earlier template logic will give the ability to display certain things depending on the category name. What exactly is the problem and what are you trying to achieve?

    -Mark

    --
    Visit My homepage and Zikula themes.
  • The problem that i have left to fix is better control of placement of the categories. It originally was setup to do a loop (foreach) that would make a new column for each category. Well, now I have more categories that before and would like to organize it differently. So now i want categories 1,2, and 3 in row 1 and 4,5 and 6 in row 2. Plus cat 7 in row 3. I think i might almost have it, but i think im having more of a formatting problem at the moment.
  • What can i do to make the variables from work, without looping it?
  • You can access array items directly via e.g. etc.

    However maybe you don't need something like this but can use HTML to your advantage. Look at the way the admin panel is implemented in .760. We use a fixed width div (the fixed width is dynamically calculated).

    -Mark

    --
    Visit My homepage and Zikula themes.
  • True, but maybe i want cat 6, then cat 8. Being able to format the data any way i want is definately a plus.
  • Im trying something like this right now for testing. But without this:

    Code

    <!--[foreach from=$link_listing item=links]-->


    it wont load the categories. When i do use it so that it loads them, the formatting is messed up. There must be a way to give the data to the below categories without doing a loop. Sry, my programming logic is shot.


    Code

    <table border="0" width="100%" cellspacing="0" cellpadding="0">
        <tr>
            <td colspan="3"><h2 style="text-align: left;">New Recommendations:</h2></td>
        </tr>
        <tr>
            <td valign="top">       <!--[if $links.category_name == "Feed Needs"]-->
    <table width="100%" align="center">
        <tr>
            <td align="left" valign="top">
            <h1 style="text-align: left;"><!--[$links.category_name]--></h1>
                <ul class="ul-reports">
                <!--[foreach name=linkloop from=$links item=link]-->
                <!--[if $link != $links.category_name]-->            
                <!--[if $smarty.foreach.linkloop.iteration == "1"]-->
                    <li class="li-latest"><span style="display:block;">UPDATE:</span></li>
                <!--[elseif $smarty.foreach.linkloop.iteration == "2"]-->
                    <li class="li-recent"><span style="display:block;">Recent Updates</span></li>
                <!--[/if]-->            
                <li class="li-content">                
                    <a href="<!--[pnmodurl modname="pxPDFManager" type="user" func="downloadpdf" pdf_id="`$link.link_id`"]-->" target="_blank"><!--[$link.link_name]--></a>
                </li>
                <!--[/if]-->
                <!--[/foreach]-->
                </ul>
            </td>
        </tr>
    </table>
            <!--[/if]--></td>
            <td valign="top"><!--[if $links.category_name == "Grain"]-->
    <table width="100%" align="center">
        <tr>
            <td align="left" valign="top">
            <h1 style="text-align: left;"><!--[$links.category_name]--></h1>
                <ul class="ul-reports">
                <!--[foreach name=linkloop from=$links item=link]-->
                <!--[if $link != $links.category_name]-->            
                <!--[if $smarty.foreach.linkloop.iteration == "1"]-->
                    <li class="li-latest"><span style="display:block;">UPDATE:</span></li>
                <!--[elseif $smarty.foreach.linkloop.iteration == "2"]-->
                    <li class="li-recent"><span style="display:block;">Recent Updates</span></li>
                <!--[/if]-->            
                <li class="li-content">                
                    <a href="<!--[pnmodurl modname="pxPDFManager" type="user" func="downloadpdf" pdf_id="`$link.link_id`"]-->" target="_blank"><!--[$link.link_name]--></a>
                </li>
                <!--[/if]-->
                <!--[/foreach]-->
                </ul>
            </td>
        </tr>
    </table>
            <!--[/if]--></td>
            <td valign="top"><!--[if $links.category_name == "Livestock"]-->
    <table width="100%" align="center">
        <tr>
            <td align="left" valign="top">
            <h1 style="text-align: left;"><!--[$links.category_name]--></h1>
                <ul class="ul-reports">
                <!--[foreach name=linkloop from=$links item=link]-->
                <!--[if $link != $links.category_name]-->            
                <!--[if $smarty.foreach.linkloop.iteration == "1"]-->
                    <li class="li-latest"><span style="display:block;">UPDATE:</span></li>
                <!--[elseif $smarty.foreach.linkloop.iteration == "2"]-->
                    <li class="li-recent"><span style="display:block;">Recent Updates</span></li>
                <!--[/if]-->            
                <li class="li-content">                
                    <a href="<!--[pnmodurl modname="pxPDFManager" type="user" func="downloadpdf" pdf_id="`$link.link_id`"]-->" target="_blank"><!--[$link.link_name]--></a>
                </li>
                <!--[/if]-->
                <!--[/foreach]-->
                </ul>
            </td>
        </tr>
    </table>
            <!--[/if]--></td>
        </tr>
        <tr>
            <td colspan="3"><h2 style="text-align: left;">Current Postions:</h2></td>
        </tr>
        <tr>
            <td valign="top">       <!--[if $links.category_name == "Livestock"]-->
    <table width="100%" align="center">
        <tr>
            <td align="left" valign="top">
            <h1 style="text-align: left;"><!--[$links.category_name]--></h1>
                <ul class="ul-reports">
                <!--[foreach name=linkloop from=$links item=link]-->
                <!--[if $link != $links.category_name]-->            
                <!--[if $smarty.foreach.linkloop.iteration == "1"]-->
                    <li class="li-latest"><span style="display:block;">UPDATE:</span></li>
                <!--[elseif $smarty.foreach.linkloop.iteration == "2"]-->
                    <li class="li-recent"><span style="display:block;">Recent Updates</span></li>
                <!--[/if]-->            
                <li class="li-content">                
                    <a href="<!--[pnmodurl modname="pxPDFManager" type="user" func="downloadpdf" pdf_id="`$link.link_id`"]-->" target="_blank"><!--[$link.link_name]--></a>
                </li>
                <!--[/if]-->
                <!--[/foreach]-->
                </ul>
            </td>
        </tr>
    </table>
            <!--[/if]--></td>
            <td valign="top"><!--[if $links.category_name == "Grain"]-->
    <table width="100%" align="center">
        <tr>
            <td align="left" valign="top">
            <h1 style="text-align: left;"><!--[$links.category_name]--></h1>
                <ul class="ul-reports">
                <!--[foreach name=linkloop from=$links item=link]-->
                <!--[if $link != $links.category_name]-->            
                <!--[if $smarty.foreach.linkloop.iteration == "1"]-->
                    <li class="li-latest"><span style="display:block;">UPDATE:</span></li>
                <!--[elseif $smarty.foreach.linkloop.iteration == "2"]-->
                    <li class="li-recent"><span style="display:block;">Recent Updates</span></li>
                <!--[/if]-->            
                <li class="li-content">                
                    <a href="<!--[pnmodurl modname="pxPDFManager" type="user" func="downloadpdf" pdf_id="`$link.link_id`"]-->" target="_blank"><!--[$link.link_name]--></a>
                </li>
                <!--[/if]-->
                <!--[/foreach]-->
                </ul>
            </td>
        </tr>
    </table>
            <!--[/if]--></td>
            <td valign="top"><!--[if $links.category_name == "Feed Needs"]-->
    <table width="100%" align="center">
        <tr>
            <td align="left" valign="top">
            <h1 style="text-align: left;"><!--[$links.category_name]--></h1>
                <ul class="ul-reports">
                <!--[foreach name=linkloop from=$links item=link]-->
                <!--[if $link != $links.category_name]-->            
                <!--[if $smarty.foreach.linkloop.iteration == "1"]-->
                    <li class="li-latest"><span style="display:block;">UPDATE:</span></li>
                <!--[elseif $smarty.foreach.linkloop.iteration == "2"]-->
                    <li class="li-recent"><span style="display:block;">Recent Updates</span></li>
                <!--[/if]-->            
                <li class="li-content">                
                    <a href="<!--[pnmodurl modname="pxPDFManager" type="user" func="downloadpdf" pdf_id="`$link.link_id`"]-->" target="_blank"><!--[$link.link_name]--></a>
                </li>
                <!--[/if]-->
                <!--[/foreach]-->
                </ul>
            </td>
        </tr>
    </table>
            <!--[/if]--></td>
        </tr>
        <tr>
            <td colspan="3"><h2 style="text-align: left;">Track Record:</h2></td>
        </tr>
        <tr>
            <td valign="top">       <!--[if $links.category_name == "Track Record"]-->
    <table width="100%" align="center">
        <tr>
            <td align="left" valign="top">
            <h1 style="text-align: left;"><!--[$links.category_name]--></h1>
                <ul class="ul-reports">
                <!--[foreach name=linkloop from=$links item=link]-->
                <!--[if $link != $links.category_name]-->            
                <!--[if $smarty.foreach.linkloop.iteration == "1"]-->
                    <li class="li-latest"><span style="display:block;">UPDATE:</span></li>
                <!--[elseif $smarty.foreach.linkloop.iteration == "2"]-->
                    <li class="li-recent"><span style="display:block;">Recent Updates</span></li>
                <!--[/if]-->            
                <li class="li-content">                
                    <a href="<!--[pnmodurl modname="pxPDFManager" type="user" func="downloadpdf" pdf_id="`$link.link_id`"]-->" target="_blank"><!--[$link.link_name]--></a>
                </li>
                <!--[/if]-->
                <!--[/foreach]-->
                </ul>
            </td>
        </tr>
    </table>
            <!--[/if]--></td>
            <td valign="top"><!--[if $links.category_name == "Blank"]-->
    <table width="100%" align="center">
        <tr>
            <td align="left" valign="top">
            <h1 style="text-align: left;"><!--[$links.category_name]--></h1>
                <ul class="ul-reports">
                <!--[foreach name=linkloop from=$links item=link]-->
                <!--[if $link != $links.category_name]-->            
                <!--[if $smarty.foreach.linkloop.iteration == "1"]-->
                    <li class="li-latest"><span style="display:block;">UPDATE:</span></li>
                <!--[elseif $smarty.foreach.linkloop.iteration == "2"]-->
                    <li class="li-recent"><span style="display:block;">Recent Updates</span></li>
                <!--[/if]-->            
                <li class="li-content">                
                    <a href="<!--[pnmodurl modname="pxPDFManager" type="user" func="downloadpdf" pdf_id="`$link.link_id`"]-->" target="_blank"><!--[$link.link_name]--></a>
                </li>
                <!--[/if]-->
                <!--[/foreach]-->
                </ul>
            </td>
        </tr>
    </table>
            <!--[else]--><!--HIDEME--><!--[/if]--></td>
            <td valign="top"><!--[if $links.category_name == "Blank"]-->
    <table width="100%" align="center">
        <tr>
            <td align="left" valign="top">
            <h1 style="text-align: left;"><!--[$links.category_name]--></h1>
                <ul class="ul-reports">
                <!--[foreach name=linkloop from=$links item=link]-->
                <!--[if $link != $links.category_name]-->            
                <!--[if $smarty.foreach.linkloop.iteration == "1"]-->
                    <li class="li-latest"><span style="display:block;">UPDATE:</span></li>
                <!--[elseif $smarty.foreach.linkloop.iteration == "2"]-->
                    <li class="li-recent"><span style="display:block;">Recent Updates</span></li>
                <!--[/if]-->            
                <li class="li-content">                
                    <a href="<!--[pnmodurl modname="pxPDFManager" type="user" func="downloadpdf" pdf_id="`$link.link_id`"]-->" target="_blank"><!--[$link.link_name]--></a>
                </li>
                <!--[/if]-->
                <!--[/foreach]-->
                </ul>
            </td>
        </tr>
    </table>
            <!--[else]--><!--HIDEME--><!--[/if]--></td>
            </tr>
    </table>
  • 'Messed up' isn't a very useful.... Try validating the HTML - maybe this is the problem. Then try to narrow the template down to just the basic components and build it back up again until you isolate the problem. This isn't one that can be easily solved in a forum post.....

    -Mark

    --
    Visit My homepage and Zikula themes.
  • I understand. It actually validates fine though. Just creates extra columns for some reason. So is there not a way for the categories to get their data without a loop?
  • Thanks for all your help everyone. Got things working. Woo hoo!

Go to page [-1] 1 - 2:

This list is based on users active over the last 60 minutes.