I am learning EE on the fly as I am creating our new corporate website in EE (at management's insistence) and I need to load different external js files depending on the template. I tried the approach below and the page in the browser doesn't show the variable as passing through even though the title variable comes through nicely.

Is there an error I don't see or is there a better way to do this?

I have a template named html_head.html coded as such:

<!DOCTYPE html>
<!--[if IE 7]> <html lang="en" class="ie7 no-js"> <![endif]-->
<!--[if IE 8]> <html lang="en" class="ie no-js"> <![endif]-->
<!--[if !IE]><!--> <html lang="en" class="no-js"> <!--<![endif]-->

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta id="view" name="viewport" content="width=device-width, maximum-scale=1.0, minimum-scale=1.0, initial-scale=1" />

    <!-- Stylesheets -->
    <link rel="stylesheet" href="{site_url}/bootstrap/css/bootstrap.min.css" />
    <link rel="stylesheet" href="{site_url}/bootstrap/css/bootstrap-responsive.min.css" />
    <link rel="stylesheet" href="{site_url}/css/styles.min.css" />

    <!--[if lt IE 9]>
        <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>

    <script src="{site_url}/js/respond.min.js"></script>
    <script src="{site_url}/js/jquery-182.min.js"></script>
    <script src="{site_url}/js/modernizr.js"></script>
    <script src="{site_url}/bootstrap/js/bootstrap.min.js"></script>
    <script src="{site_url}/js/page_scripts/{embed:page_script}.js"></script>


and I am calling this from other templates as such:

{embed="embeds/html_head" page_title="Company Name" page_script="home"}

But as mentioned page_title works but page_script doesn't. Any help is appreciated.

Thanks in advance!

  • What is actually being output by your HTML? What, if anything, is taking the place of page_script in your script tag? In short, what you are doing doesn't look wrong so perhaps it isn't working because the script path isn't correct or there is an error in the file. – foamcow Apr 17 '13 at 11:33
  • this is the output: <script src="dev-edrweb.edrtrust.com/js/page_scripts/.js"></…> – jgravois Apr 17 '13 at 11:45
  • I tried this code locally on my machine and everything works fine. This is probably not a problem with your source. What version of EE are you running? – Johnathan Waters Apr 17 '13 at 14:51
  • 1
    Can you get {embed:page_script} to work anywhere else in the template for testing purposes? – Stephen Callender Apr 17 '13 at 14:56
  • I am using EE 2.5.5 – jgravois Apr 17 '13 at 15:21

Try these two things and see what you get.

1) Put {embed:page_script} somewhere else in the template and see if you have the same results.

2) Create a new parameter in the embed= tag and see if get's passed through.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.