addHeaderItem()

Permalink
Is there a way such as using addHeaderItem() to add a php include statement to the header dynamically rather than adding the include directly into the template header.
I want the inclusion to be dynamic and not static.

basically... should this work..?
$this->addHeaderItem("<?php include('folder/file.php') ?>");
...I am asking because this doesn't seem to work.

JimboJetset
 
RadiantWeb replied on at Permalink Reply
RadiantWeb
http://www.concrete5.org/community/forums/customizing_c5/a-simple-block-to-add-script-to-header/

I wrote this for this type of application.

Chad
JimboJetset replied on at Permalink Reply
JimboJetset
Thanks Chad.. but it doesn't seem to work...

If I manually add <?php include('folder/file.php') ?> to the template header my stuff works

I installed your block...and...

If I use your block and add <?php include('folder/file.php') ?> to the textarea box my stuff doesn't work.

If I upload my php file to the library then use your block to select the file, my stuff doesn't work.

likewise if I use addHeaderItem('<?php include(\'folder/file.php\') ?>'); in my own controller my script doesn't work...

I think it may be to do with how the page is rendered...

Any other ideas...
RadiantWeb replied on at Permalink Reply
RadiantWeb
no no no...look at how it works bro. lol

you either 1.) upload your script to your files dir and add that file, or 2.) copy and paste all the actual script.

although, I think I wrote the text input field just for <script>...but you could easily modify the code to be any type of code.

Chad
RadiantWeb replied on at Permalink Reply
RadiantWeb
let me check the code and see if I can make it work for php
RadiantWeb replied on at Permalink Reply
RadiantWeb
what are doing adding php to a header exactly?

if you are just trying to get some java, then use my addon, and just add the java script, and do not use php at all.

please explain, and I can perhaps customize this addon. But I never have had a reason to add php to a header...just trying to wrap my head around what you could be doing exactly.

Chad
JimboJetset replied on at Permalink Reply
JimboJetset
sorry to waste your time chad... I've sorted this now... I forgot I could use include_once to stop multiple blocks trying to include the same php file multiple times... this was why I was using the addToHeader idea as this guarantees a single entry...

It doesn't solve the riddle of why addToHeader didn't work though... maybe a puzzle for another time..

Thanks for the help though... much appreciated.
JimboJetset replied on at Permalink Reply
JimboJetset
I have since found that the code is indeed being placed in the header but it seems the php script is not being evaluated.