Fork me on GitHub

Template logic was working, now isnt.  Bottom

Go to page 1 - 2 [+1]:

  • Here is the URL:

    index.php?module=pxPDFManager&type=user&private=1

    Code

    <!--[if $private != "1"]-->
    Content1
    <!--[else]-->
    Content2
    <!--[/if]-->


    Was working fine, but then all of a sudden it stopped working. (im talking about a 5 min period while i was making the template). So basically its showing Content1 all the time now. It worked perfect, then not.

    Its not being cached as i have $pnRender->caching = false; in the pnuser.php file.

    Also, on a side note. I was trying out for another situation within the template.

    Code

    <!--[foreach from=$link_listing item=links]-->
            <!--[if $links.category_name != "Track Record"]-->
    blah blah blah
                <!--[/if]-->
                <!--[/foreach]-->


    And it works fine, but I would like to be able to list more than one category to not show. I have tried it using Smarty logic in pnuser.php and the actual template and still have not been able to use an array that lists multiple categories. Any tips on this too?
  • 1. Not entirely sure, Xanthia caching perhaps? Browser caching?

    2.

    Code

    <!--[if $links.category_name != "Track Record" OR $links.category_name != "Something else"]-->
    blah blah blah
                <!--[/if]-->


    Maybe?

    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • Dont think it would be browser caching, and I already tried the second one. For some reason that didnt work and I would rather be able to do more than two. Thanks for trying though. I tried using google and checking out the Smarty docs, but for some reason i cant figure it out.
  • Tried this, which should work, but didnt either.

    Code

    <!--[if $links.category_name != "Track Record" || $links.category_name != "Livestock"]-->


    This works though.

    Code

    <!--[if $links.category_name != "Track Record"]-->


    Odd
  • What I posted above works fine for me...

    I use this in my module:

    Code

    <!--[if $cat[set].fieldtype eq 1 OR $cat[set].fieldtype eq 5 OR $cat[set].fieldtype eq 9 OR $cat[set].fieldtype eq 10 OR $cat[set].fieldtype eq 6]-->


    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • works with equal, but not with "not equal" (ie !=)

    so basically this works:

    Code

    <!--[if $links.category_name eq "Track Record" OR $links.category_name eq "Livestock"]-->


    But this doesnt:

    Code

    <!--[if $links.category_name != "Track Record" OR $links.category_name != "Livestock"]-->


    And I still havent figured out why the $private if statement isnt working anymore. I have tried different browswers, clearing cache. Making sure its not caching. Still no luck.
  • As far as the private problem, i gave up and moved the logic to the pnuser.php file and that works fine now. But i still need help with the above category problem.

    Here is what i put in the pnuser.php file for the private template issue. So now i have second template file, but its not that big of a deal.

    Code

    if ($private == 1) {
        return $pnRender->fetch('pxpdfmanager_user_private.htm');
        } else {
        // Return the output that has been generated by this function
        return $pnRender->fetch('pxpdfmanager_user_main.htm');
        }
  • have you tried ne instead of != ??
  • Also, have you considered the security implications of having a private area simply accessed by adding &private=1 to the URL?

    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • yeah, i already have the security check in place.
  • hmm, this thing is being picky. MarkWest, think you could chime in? This is driving me nuts. Logically the logic should work, but its not. Feel like im back in the military.
  • What hasn't been asked before is how is the variable private getting from the URL to the template? Perhaps posting the relevant portion of PHP code would be helpful.

    Check a value for private is available to the template by either adding the debug tag or outputing the prviate variable directly .

    -Mark

    --
    Visit My homepage and Zikula themes.
  • Forgot all about pndebug. Thanks! The original point of the template for the module was to just have 1 row and 4 columns. Here is the template code for that:

    Code

    <table width="100%" align="center">
        <tr>
            <!--[foreach from=$link_listing item=links]-->
            <td align="left" valign="top" style="padding: 0px 0px 0px 0px">
            <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>
            <!--[/foreach]-->
        </tr>
    </table>


    What im trying to do now is have 3 rows and 3 columns. Or whatever way i want it. Im trying to either filter or statically assign where I want each category to appear. Here is the code for the PHP function taken from pnuser.php.

    Code

    /**
     * the main user function
     *
     * This function is the default function, and is called whenever the module is
     * initiated without defining arguments.  As such it can be used for a number
     * of things, but most commonly it either just shows the module menu and
     * returns or calls whatever the module designer feels should be the default
     * function (often this is the view() function)
     *
     * @param       void
     * @return      string                          This is the output for the main
     *                                              page of this module.
     */

    function pxPDFManager_user_main(){
        // Security check - important to do this as early as possible to avoid
        // potential security holes or just too much wasted processing.  For the
        // main function we want to check that the user has at least overview
        // privilege for some item within this component, or else they won't be
        // able to see anything and so we refuse access altogether.  The lowest
        // level of access for administration depends on the particular module, but
        // it is generally either 'overview' or 'read'
        if (! pnSecAuthAction(0, 'pxPDFManager::', '::', ACCESS_READ)) {
            return pnVarPrepHTMLDisplay(__ERROR_PXPDFMANAGER_NOAUTH);
        }
       
        // Get the private setting from input.
        $private = pnVarCleanFromInput('private');

        // Check to see if we should see the private or public
        // categories.
        if (! isset($private)) {
            $private = 0;
        }

        // Check to see if the user is logged in or not. This prevents
        // unauthorized access to the links.
        if (! pnUserLoggedIn()) {
            $private = 0;
        }

        // Create output object - this object will store all of our output so that
        // we can return it easily when required
        $pnRender =& new pnRender('pxPDFManager');

    // As Admin output changes often, we do not want caching.
        $pnRender->caching = false;

        // Get the links listing.
        $links_listing = pnModAPIFunc('pxPDFManager',
                                      'user',
                                      'getlisting',
                                      array('private' => $private));

        $pnRender->assign('link_listing', $links_listing);
       
        // Loop through the links listing and assign the template variables.
        foreach ($links_listing as $list_name => $list_pdfs) {
            // Assign the links listing for the template.
            $pnRender->assign($list_name, $list_pdfs);
        }

        if ($private == 1) {
        return $pnRender->fetch('pxpdfmanager_user_private.htm');
        } else {
        // Return the output that has been generated by this function
        return $pnRender->fetch('pxpdfmanager_user_main.htm');
        }
    }
  • odd, looks like $private isnt being passed anymore. Page loads correctly though. Hmm. But as you can see in the PHP code, i decided to take care of that problem in the PHP file instead of the template. As far as the categories, i just need to load them instead of doing a loop i guess and just hard code their position. Im trying to brush up on my programming and cant think of how to just load all the categories instead of looping them. I know its easy, doh.
  • I don't see 'private' being assigned to the template anywhere in the PHP code.

    -Mark

    --
    Visit My homepage and Zikula themes.

Go to page 1 - 2 [+1]:

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