Header Extra Content - PHP doesn't get executed

Permalink
I need to add an extra .js file to a certain page's header.

I type into the page's Header Extra Content attribute the followong:
<script src="<?php echo $this->getThemePath()?>/js/plugins.js"></script>


And I see the exact same thing in the page's source, so the php code didn't change into the actual theme path.

How can I solve this problem? It is extremely annoying, since if I include the the js file in my theme's header, the editing stops working on every page, except the one that needs this file to work.

Thanks in advance.

Additional info: It's on my local machine, that's why I need to use the php themepath. The file in question is related to Google maps directions "plugin" (it isn't a block, I just inserted the HTML and CSS into the actual page, but it needs the js file in the header)

View Replies: View Best Answer
JohntheFish replied on at Permalink Best Answer Reply
JohntheFish
That is because the attribute takes text, not php.

As to how to solve it, the best solution is a block controller's on_page_load handler calling addHeaderItem.

If you want to hack a block to do that for you, a good starting point is the Load jQuery.UI block or the basic html block.
gd42 replied on at Permalink Reply
Sadly I have no programming experience, I only know HTML and CSS, so figuring these things out takes considerable ammount of time.

If I can't use the header extra content attribute, it might be easier to do it with a conditional comment hardcoded into the theme, isn't it?
(That way I don't have to deal with making a new block. On the page I used the default html block to insert the code, so for me it doesn't make a lot of sense to make a new block just to insert one line into the header.)

I know that php conditional comments exist, and it can read the page ID, so I need something like "if page ID is "X", insert "the code I tried to insert into the header extra code attribute".

Can you help me with this?

Thanks for your answer.
pumppi replied on at Permalink Reply
You could hardcode the theme path.

<script src="<?php echo $this->getThemePath()?>/js/plugins.js"></script>


<script src="http://wwww.my-own-site.com/themes/theme-name/js/plugins.js"></script>
nerdess replied on at Permalink Reply
nerdess
or just put the js file into the /js folder of the concrete5 root and add into "Extra Header Content" because then you don't have to hardcode the theme path.

<script type='text/javascript' src='/js/scripts.js'></script>


more infos here:http://www.concrete5.org/community/forums/usage/where-to-put-extra-...