Custom PHP Page - Using Variable inside Template?
#1
Hello, so here I am again with yet another problem, I might be really tired or I just can't figure it out.

I'm outputting a page through a template, just like normal, but before I do that I declare some variables.

$pe_name = "name";

inside the template I have
{$pe_name}

but nothing shows up.

here's some code for y'all.

$pe_name = "";
$pe_avatar = "";
$pe_image = "";
$pe_title = "";


$selected_uid = $mybb->get_input('ushowid');

    $query = $db->simple_select("users", "*", "uid='".$selected_uid."'", array(
        "order_by" => 'uid',
        "order_dir" => 'DESC',
        "limit" => 1
    ));
    
    $foundUser = $db->fetch_array($query);
    
    if ($foundUser['uid'] > 0) {
        
        $pe_name = $foundUser['username'];
        $pe_avatar = $foundUser['avatar'];

        if ($pe_avatar == "") {
            $pe_avatar = "/images/default_avatar.png";
        }

        $pe_title = "My Portfolio!";
        $pe_image = "https://www.paintoolkit.org/assets/img/backgrounds/background-banner-tools.jpg";

        $page2show = "show_user";
    } else {
        $page2show = "show_list";
    }

then it reaches switch statement right after which is working, it outputs the right template, but the template aren't catching onto those variable.

I still haven't reached a feasible solution yet, any solution would be lovely.

I tried making an arary at start of file like

$pe_user = array("username" => "name");

That works well, I can call that, but if I try to change that array nothing happens.


No help ?
Reply
#2
So I found a solution, apparantly any operation after eval'ing the templates somehow messes everything up, so I moved the eval's to just before my switch and everything's working now.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)