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.

Using php in forum templates - syntax check and login redirect question

July 11, 2007 3:08am

Subscribe [1]
  • #1 / Jul 11, 2007 3:08am

    WCW

    6 posts

    I’m a php newbie and am looking for some reassurance or advice.  Php is turned on for my forum templates (I’m using them for registration and member profiles too, rather than the member templates) and I’ve added some conditional code in one of the global templates (page header) to change out a graphic depending on the url of the page. I’m using global variables defined in my path.php file as per the following snippet.

    $segs = explode("/", $_SERVER['PATH_INFO']);
    $global_vars = array(
    "seg_1" => $segs[1],
    "seg_2" => $segs[2],
    "seg_3" => $segs[3],
    "seg_4" => $segs[4],
    "seg_5" => $segs[5],
    "seg_6" => $segs[6],
    "seg_7" => $segs[7],
    "seg_8" => $segs[8],
    "seg_9" => $segs[9]
    );

    Does the php hack below (which seems to be working - “crosses fingers” ) check out in terms of safe php syntax, proper use of quotation marks and such? Is there a cleaner/smarter way to handle it?  I’m using the input class function…

    <?php
    global $IN;
    if ($IN->global_vars['seg_3'] == "profile")
    { echo 'http://www.creducation.org/themes/forum_themes/developer/images/forumprofilelogo.gif';
    } elseif ($IN->global_vars['seg_4'] == "profile")
    { echo 'http://www.creducation.org/themes/forum_themes/developer/images/forumprofilelogo.gif';
    }
    elseif ($IN->global_vars['seg_3'] == "register")
    { echo 'http://www.creducation.org/themes/forum_themes/developer/images/forumregisterlogo.gif';
    }
    elseif ($IN->global_vars['seg_3'] == "login")
    { echo 'http://www.creducation.org/themes/forum_themes/developer/images/forumloginlogo.gif';
    }
    else { echo '<a href="http://www.creducation.org/cre/forum/" title="CRE Forums">http://www.creducation.org/themes/forum_themes/developer/images/forumlogo.gif</a>';
    }
    ?>

    A related question I’m also working through has to do with problems with “page not found errors” after people login or register to the site using my forum templates. Any advice on how to fix this would be welcomed as well. I’m not sure if the “return=” parameter is workable within my forum templates. Adding it did not seem to remedy the problem

    I’m running ExpressionEngine 1.6.0 Build:  20070621

    Thanks in advance…

  • #2 / Jul 11, 2007 10:12am

    Robin Sowell

    13255 posts

    I don’t spot anything problematic- but I’ll have the crew eyeball it just in case I’m missing something.  You can also use the input class to grab your segments:

    $IN->fetch_uri_segment('x');

    Which is the approach I’d take for extra peace of mind. 

    As to the page not found errors- is this consistently a problem?  Can you link to the site in question?  The login form can be overriden by specifying an extra hidden RET field to take them where you want.  But by default, it shouldn’t be showing ‘page not found’.  Now the registration page is a bit different- I believe it always takes you to the main page- should be home page or main forum page.  Are you running your forum inside the regular templates?  And where are both forum login and forum registration redirecting to?

  • #3 / Jul 11, 2007 12:04pm

    WCW

    6 posts

    Robin,
    Thanks for taking a look for me, and so quickly. I’ll have a go at using the method you suggest.
    An example of a conditional using the $IN->fetch_uri_segment might help me out if you can point me to one.

    With respect to the login redirect, people are initially directed to
    http://www.creducation.org/cre/forums/member/login/

    My redirect problem seems to only happen if people are using the “mini-login” form at top right, rather than when they use the larger full login form also appearing on this page. Seems like I should try and hide the “mini-form” on the login page…

    I just did another test on the registration form, and am waiting for the user activation email to come back, so I’ll have to provide more information after I’ve run through that process again.

    Thanks again.
    Bill

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

ExpressionEngine News!

#eecms, #events, #releases