Custom PHP variable in VB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Alex1200GS
    New Member
    • Jul 2007
    • 15
    • 3.8.x

    Custom PHP variable in VB

    Hi all,

    this issue has been puzzling me for a while and I could use your help please.
    I have a VB installation on http://forum.beer.gr, with a special skin used to have the same look and feel with the rest of the site. Just below the green navigation bar, on the left hand side corner, the current date should appear, in Greek.

    Here comes trouble. In order to display the date correctly in Greek, I created a small PHP script which assigns the correct output to a variable named $greekdate. Here's the script:

    PHP Code:
    $beerdays = array('Δευτέρα','Τρίτη','Τετάρτη','Πέμπτη','Παρασκευή','Σάββατο','Κυριακή'); 
    $beermonths = array('Ιανουαρίου','Φεβρουαρίου','Μαρτίου','Απριλίου','Μαΐου','Ιουνίου','Ιουλίου','Αυγούστου','Σεπτεμβρίου','Οκτωβρίου','Νοεμβρίου','Δεκεμβρίου'); 
    $greekdate $beerdays[date('w')]." ".date('j')." ".$beermonths[date('m')-1]." ".date('Y');
    echo 
    $greekdate
    I then created a plugin with the following code:

    PHP Code:
    ob_start();
       include(
    'gd.php');
       
    $greekdate ob_get_contents();
    ob_end_clean(); 
    Now, I used the $greekdate variable inside the header template, and I expected the Greek date to display on that corner. Instead, the variable is not parsed and "$greekdate" is dumped on the screen.

    On a previous effort, I entered the PHP script directly inside the plugin (without including an external file), but that didn't work either.

    Why isn't VB parsing my variable? What have I missed?
    Any input would be appreciated, thanks.

    Alex
  • Alex1200GS
    New Member
    • Jul 2007
    • 15
    • 3.8.x

    #2
    PS: Until I find the solution to this, I'm manually updating the date in the header template every midnight...

    Comment

    • David Grove
      Senior Member
      • Apr 2008
      • 3507
      • 5.5.x

      #3
      What hook are you using? Make sure your hook is evaluated before the header template is in global.php. The global_start hook should be fine. Also you don't need to use output buffering for this. Remove the echo statement from your file, then include it using your plugin, and you'll have $greekdate available at that point.
      ~~~~~

      Comment

      • Alex1200GS
        New Member
        • Jul 2007
        • 15
        • 3.8.x

        #4
        Pardon the omission, I was using the global_start hook indeed.

        However, I managed to figure out what was wrong: the skin designer had dumped all the HTML code that replicated the main site's header strip inside a replacement variable named {header} which was inserted on top of the actual header template.

        I assumed that replacement variables come into play after the code parsing process, so I took that part out of the variable and into the actual template. No luck.

        Then I re-used output buffering by reinstating the echo line in the included file and it finally worked.

        Thanks sockwater.

        Comment

        widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
        Working...