Jump to content

A bit confused? Please advise on {if}code{/if}


Recommended Posts

Greetings. I am using this forum for the first time, so any guidance or help is appreciated in advance.


I am Running the latest version (Top hats of to WHMCS on this update)


I am choosing to use the knowledge base as my product showcase area and "articles" are placeholder pages for individual "Product Details" I link to these pages with MORE DETAILS in product descriptions for cart.


I am using the Default template.


I am attempting to edit knowledgebasecat.tpl


The idea is that when the user selects a KB category they will see some additional graphics and text pertaining to that top level selection.


I am attempting to get a simple message to appear first. My theory is based on the kbcat.id


my experimental code is as follows:


{if $kbcat.id eq "5"} Product Category 5 {/if}


I am have been stuck on this for a few hours, I am a bit confused as simple as it is doesn't want to work with me. If anyone could share a bit of expertise with me here I would greatly appreciate the help. I really want to understand why and how this should work.


Wishing you a happy holidays!:-)

Link to comment
Share on other sites

Try this instead. I am not able to test at the moment....


{if $kbcat.id == "5"} Product Category 5 {/if}


See http://php.net/manual/en/language.operators.comparison.php


i know the above refers to native PHP code (not Smarty), but the double equals sign is a standard format used in Perl, PHP and many other languages to compare a variable to a number. eq is meant for strings.

Edited by Lawrence
Link to comment
Share on other sites

Thanks guys, I got responses for Christmas.


The code is as documented by whmcs, and smarty.


{if $kbcat.id eq "5"} then say this{/if}


Only it does not seem to work on this template file.


Tried to use the == no luck there either. I will post the entire code chunk here, just will have to be when I get back to my desk.


The statement and function works anywhere else, just not on this page? Like I said it shouldn't even be an issue it's so simple, but perhaps there is something else in that block quote I am missing?


Thanks gents for your input...I'm listening to Newfie music in your honor!


Will post entire page source soon.

Link to comment
Share on other sites

Here is the complete code:

{include file="$template/pageheader.tpl" title=$LANG.knowledgebasetitle}




<br />

{if $kbcat.id eq "5"}Say hello{/if}

<div class="well">

<div class="textcenter">

<form method="post" action="knowledgebase.php?action=search" class="form-stacked">


<input class="bigfield" name="search" type="text" value="{if $searchterm}{$searchterm}{else}{$LANG.kbquestionsearchere}{/if}" onfocus="this.value=(this.value=='{if $searchterm}{$searchterm}{else}{$LANG.kbquestionsearchere}{/if}') ? '' : this.value;" onblur="this.value=(this.value=='') ? '{if $searchterm}{$searchterm}{else}{$LANG.kbquestionsearchere}{/if}' : this.value;"/>

<input type="submit" class="btn large primary" value="Search" />






{if $kbcats}

{include file="$template/subheader.tpl" title=$LANG.knowledgebasecategories}


<div class="clearfix">

{foreach from=$kbcats item=kbcat}

<div class="col4">

<div class="internalpadding">

<img src="images/folder.gif" /> <a href="{if $seofriendlyurls}knowledgebase/{$kbcat.id}/{$kbcat.urlfriendlyname}{else}knowledgebase.php?action=displaycat&catid={$kbcat.id}{/if}" class="fontsize2"><strong>{$kbcat.name}</strong></a> ({$kbcat.numarticles})<br />








{include file="$template/subheader.tpl" title=$LANG.knowledgebasearticles}


{foreach from=$kbarticles item=kbarticle}

<div class="row">

<img src="images/article.gif"> <a href="{if $seofriendlyurls}knowledgebase/{$kbarticle.id}/{$kbarticle.urlfriendlytitle}.html{else}knowledgebase.php?action=displayarticle&id={$kbarticle.id}{/if}" class="fontsize2"><strong>{$kbarticle.title}</strong></a><br />




<br />

<p class="fontsize3 textcenter">{$LANG.knowledgebasenoarticles}</p>

<br /><br /><br />


It is strange? Won't work off of either kbcat.id or kbcat.name. Again, thanks for your attention and any help is appreciated.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated