Variables in include file, added in header block, not available to view file

edited September 2011 in Share
Hello everyone, please i need some help.
I got a php file with some variables (like a config file) that i required (included) in the header of my header file (header block).

When i try to access these variables from my view files, i get a php error : undefined variable.

so i then did an include of the same file in the view file, every thing works except i am getting nasty notices and errors such as:

A PHP Error was encountered

Severity: Notice

Message: Constant THUMBSTEXT already defined

Filename: confs/e2config.php

Line Number: 24

Please help, this project was due last week.

Comments

  • Can you post some code please?
  • edited 4:16PM
    from my header (header layout block)

    <?php require($_SERVER['DOCUMENT_ROOT'].'/########/assets/confs/e2config.php');?>

    contents of e2config.php (some)

    image/loading_hill.gif" width="50" height="50" alt="" id="bar" />



    image/play.png" title="<?php echo PLAYTEXT;?>" border="0" align="absmiddle" class="controls" rel=" " /> |
  • Can you just include the e2config.php file in each view and not in the header block without getting errors? I know this is not the ideal solution, but it might be a work around until someone else can chime in with a better solution.
  • edited 4:16PM
    Hard to tell what's going on without seeing the full code.

    Maybe you could try and include these constants in the global.php variables file, instead of using an includes?
  • edited 4:16PM
    I think Tallowman's idea of putting it into the global.php variable may be a good idea.
  • edited 4:16PM
    Thank you but please can you show me an example on how to do it.
    like with these


    define('THUMBSTEXT', 'Toggle Thumbs');
    define('GALLERIESTEXT', 'View Galleries');
    define('INFOTEXT', 'View Info');
    define('PLAYTEXT', 'Play Slideshow');
    define('PAUSETEXT', 'Pause Slideshow');


    and the global.php file your referring to, is the global variables file in the view folder ?

    thanks in advance
  • edited 4:16PM
    @toymachiner62
    i thought of that, but some css and js paths depend on some variables in the include file.

    Thanks though
  • edited 4:16PM
    You can try just pasting those constants in the fuel/application/views/_variables/global.php file.
  • edited 4:16PM
    Thank you so much Admin, I will do just that.
  • edited 4:16PM
    Thank you so much that worked nicely.
Sign In or Register to comment.