No announcement yet.

Custom PHP variable in VB

  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 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');
    I then created a plugin with the following code:

    PHP Code:
    $greekdate ob_get_contents();
    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.


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


    • #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.


      • #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.


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