ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Custom Forum Headers trying - 'if category name =='

July 23, 2007 2:52pm

Subscribe [1]
  • #1 / Jul 23, 2007 2:52pm

    lemonman

    68 posts

    Hi all,
    I am trying to set custom headers for each section of my forum.

    I am expecting i should be able to do some sort of basic ‘If..’ statemtn basedon {category_name}.

    I have opened my forum default tmeplate and found this line of code that i wish to alter..

    so I want to say
    {if category_name =="Black Section"}
    color=#000000
    {/if}

    Here’s the line of code i want to change. What is the proper syntax to use in this forum template environment?

    <td class="tableHeadingBG" colspan="4"><div class="tableHeading">{if category_name =="Black Section"}
    color=#000000
    {if:else}{category_name}{/if}</div>
     {if category_description}<div class="tableHeadingSmall">{category_description}</div>{/if}
    </td>

    Thanks for any help you may be able to give.
    L

  • #2 / Jul 23, 2007 4:19pm

    Lisa Wess

    20502 posts

    Hi, lemonman,

    I’ve deleted your post in Technical Support - this is the correct forum; there is no need to cross-post, we will move posts if needed.

    Have you seen this kb entry? Also, what template are you modifying, exactly?

  • #3 / Jul 23, 2007 5:22pm

    lemonman

    68 posts

    Modifying

    Index Page Templates >
    Forum Main Index Page
    Forum Main Wrapper
    Forum Table Footer
    Forum Table Heading
    Forum Table Rows

    Got it to work based on css style setup based on category id but still can’t work a conditional into the mix.

    So now I have:

    <div id="header{category_id}">
    
    
    <!-- xyz -->
    {category_name}</div>
    
    
    </div>

    :(

  • #4 / Jul 23, 2007 5:29pm

    Lisa Wess

    20502 posts

    The forums do work on a bit of a different parser. I would first try outputing those variables directly - but you may need to turn on PHP parsing and use PHP to evaluate that instead of EE conditionals.

  • #5 / Jul 23, 2007 5:58pm

    lemonman

    68 posts

    Cool, i figured as such.
    Wondering how would i get this to go.

    <?php global $PREFS;
    
    $db = mysql_connect( // Handle the connection to the database.
    $PREFS->core_ini['db_hostname'], // hostname,
    $PREFS->core_ini['db_username'], // username and
    $PREFS->core_ini['db_password']); // password are automatically pulled
    mysql_select_db($PREFS->core_ini['db_name']); // from EE's config.php
    
    // Adjust your query as needed. In this example, the ids of all open entries from
    // weblog_id 1 are queried:
    
    $query = "SELECT forum_name from exp_forums WHERE forum_id = {category_id}";
    
    // the result is stored in $result, the number of returned rows in $num:
    $num = mysql_numrows($result = mysql_query($query,$db));
    
    mysql_close(); // close the connection to the database
    
    // now we loop through the results and actually do some stuff:
    
    for ($i = 0; $i <= $num-1; $i++) {
    
    $id = mysql_result($result,$i,"entry");
    print $id . '
    '; } ?>
  • #6 / Jul 24, 2007 12:23pm

    lemonman

    68 posts

    ok , modified the plugin to allow for cat_url_title.
    I have sent along to Yvonne for redeployment.

    Great stuff! Thanks for all your replies.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases