Jump to content

PHP variable on custom page


Bradpl6

Recommended Posts

Hi all,

I'm having a bit of a struggle with the custom .htm pages, I can get php to work however when it comes to things like <? echo $pilotcode; ?> they won't display. I understand it's to do with the defining variable not being passed to the custom page but can't figure out how to solve it. Any suggestions or solutions?

Link to comment
Share on other sites

Ahh thanks. I've just tried to include codon.config.php however I'm finding difficulty in doing this too, absolute directories won't work nor will navigating up a directory using the old ../../ method.

Edit

This is what I have in my .htm file in the 'pages' folder.

<?
include('../codon.config.php');
  Template::Show('featchartvote.tpl');
?>

Edited by Bradpl6
Link to comment
Share on other sites

  • Administrators

I always do:

include dirname(__FILE__).'/../path/to/file';

The dirname(__FILE__) gives the absolute path to the file you're at now, and from there you can navigate to wherever that codon.config.php file is. Using the absolute path to that file is best though

Link to comment
Share on other sites

Guest lorathon

You need to fill the variable prior to echoing it.

explain exactly what you are trying to do. If this page will be customized for each pilot (like the Pilot info Center) then use in the template at the top.

<?php
$pilot = AUTH::$userinfo; //Retrieve the logged in pilots info
$pilotcode = PilotData::getPilotCode($pilot->code, pilot->pilotid);
?>

All of this can be preloaded in the module as such

$this->set('pilot', AUTH::$userinfo);
$this->show('my_template.tpl');

or

Template::Set('pilot', AUTH::$userinfo);
Template::Show('my_template.tpl');

Link to comment
Share on other sites

You need to fill the variable prior to echoing it.

explain exactly what you are trying to do. If this page will be customized for each pilot (like the Pilot info Center) then use in the template at the top.

<?php
$pilot = AUTH::$userinfo; //Retrieve the logged in pilots info
$pilotcode = PilotData::getPilotCode($pilot->code, pilot->pilotid);
?>

All of this can be preloaded in the module as such

$this->set('pilot', AUTH::$userinfo);
$this->show('my_template.tpl');

or

Template::Set('pilot', AUTH::$userinfo);
Template::Show('my_template.tpl');

Thanks, that worked brilliantly!

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

Loading...
×
×
  • Create New...