ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

If not embed, then what else can I use?

October 09, 2008 12:38pm

Subscribe [1]
  • #1 / Oct 09, 2008 12:38pm

    Dan Lee

    12 posts

    Hey there! first post, be nice 😊

    So I found ee and I’m loving it. And I started to dabble with the templates and found the embed variable and thought to myself “awesome, I don’t have to link to style sheets and enter all of the same head info over and over again.” so I gave it one of these:

    {embed="mygroup/headinfo"}

    The headinfo template was, obviously, all of my head info. Welp, turns out that that embeds are the last thing to process. So my style sheets and other info were no processing until the end and were not applying to the page.

    My question: If embeds don’t work for this, what can I use so I can create a template for all of my head info and apply it to each page?

    Thanks in advance guys.

  • #2 / Oct 09, 2008 12:43pm

    Lisa Wess

    20502 posts

    Hi, Dan - welcome to the forums!

    The templates are parsed before being delivered to the page; so your stylesheets should absolutely show up.  The majority of users do as you attempted to do, and do it successfully - myself included.

    Can you perhaps share the contents of your headinfo template, and a link to the site using that method, so we can help troubleshoot it?

  • #3 / Oct 09, 2008 1:02pm

    Dan Lee

    12 posts

    Thanks for the quick reply. I’m using the same head info as the default page that comes with ee:

    <head>
    <title>{exp:weblog:info weblog="{my_weblog}"}{blog_title}{/exp:weblog:info}</title>
    <meta http-equiv="Content-Type" content="text/html; charset={charset}" />
    
    <link rel='stylesheet' type='text/css' media='all' href='{stylesheet={my_template_group}/style_css}' />
    <style type='text/css' media='screen'>@import "{stylesheet={my_template_group}/style_css}";</style>
    
    <link rel="alternate" type="application/rss+xml" title="RSS" href="{path={my_template_group}/rss_2.0}" />
    <link rel="alternate" type="application/atom+xml" title="Atom" href="{path={my_template_group}/atom}" />
    
    </head>

    My template group is called devbeerg and my template is called page_head, so my code that I’m using in my index page is {embed="devbeerg/page_head"}

    My outcome is this. Be nice, its my dev site that I play around with.

  • #4 / Oct 09, 2008 1:07pm

    Lisa Wess

    20502 posts

    Well, I can tell you immediately why the stylesheet isn’t showing - the EE tags are not being parsed:

    <title>{exp:weblog:info weblog="{my_weblog}"}{blog_title}{/exp:weblog:info}</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <link rel='stylesheet' type='text/css' media='all' href='http://dev.stpetersbeerg.com/index.php?css={my_template_group/style_css}' />
    <style type='text/css' media='screen'>@import "http://dev.stpetersbeerg.com/index.php?css={my_template_group/style_css}";</style>
    
    <link rel="alternate" type="application/rss+xml" title="RSS" href="http://dev.stpetersbeerg.com/index.php/{my_template_group//rss_2.0}" />
    <link rel="alternate" type="application/atom+xml" title="Atom" href="http://dev.stpetersbeerg.com/index.php/{my_template_group//atom}" />

    in your source.  The page_head template - what template type is it set to?

  • #5 / Oct 09, 2008 2:49pm

    Dan Lee

    12 posts

    It was originally set to static but your reply prompted me to change it to web page. However that did not work either. Is there something that I need to put around my <head> tags so it knows that the ee tags should be parsed?

  • #6 / Oct 09, 2008 2:56pm

    Lisa Wess

    20502 posts

    It should work with Web Page.  If you visit the template directly, does it work?

  • #7 / Oct 09, 2008 2:58pm

    Dan Lee

    12 posts

    No…

    It sure doesn’t, which is actually kind of weird. Its taking me to

    http://dev.stpetersbeerg.com/index.php/devbeerg/page_head/

    Maybe this is a bigger issue than first thought. I created more templates under this template group and they didn’t work. Perhaps I’m missing something somewhere…

  • #8 / Oct 09, 2008 3:06pm

    Lisa Wess

    20502 posts

    That no input file specified is covered by this kb entry.

  • #9 / Oct 09, 2008 3:56pm

    Dan Lee

    12 posts

    Well thanks for that. I’m all set there now. The templates display just fine now. I created a test template and it looks good. I am still having an issue with the embed now and I don’t think it has to do with the fix that you just gave me in the kb. Here’s why:

    My template is this:

    <head>
    <title>{exp:weblog:info weblog="{my_weblog}"}{blog_title}{/exp:weblog:info}</title>
    <meta http-equiv="Content-Type" content="text/html; charset={charset}" />
    
    <link rel='stylesheet' type='text/css' media='all' href='{stylesheet={my_template_group}/style_css}' />
    <style type='text/css' media='screen'>@import "{stylesheet={my_template_group}/style_css}";</style>
    
    <link rel="alternate" type="application/rss+xml" title="RSS" href="{path={my_template_group}/rss_2.0}" />
    <link rel="alternate" type="application/atom+xml" title="Atom" href="{path={my_template_group}/atom}" />
    
    </head>

    Which is displaying this:

    <head> 
    <title></title> 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
     
    <link rel='stylesheet' type='text/css' media='all' href='http://dev.stpetersbeerg.com/index.php?css={my_template_group/style_css}' /> 
    <style type='text/css' media='screen'>@import "http://dev.stpetersbeerg.com/index.php?css={my_template_group/style_css}";</style> 
     
    <link rel="alternate" type="application/rss+xml" title="RSS" href="http://dev.stpetersbeerg.com/index.php/{my_template_group//rss_2.0}" /> 
    <link rel="alternate" type="application/atom+xml" title="Atom" href="http://dev.stpetersbeerg.com/index.php/{my_template_group//atom}" /> 
     
    </head>

    Which means my title and my meta information are working just great, but it can’t for some reason, interpret my css pages. For the record, my css pages are in the same template group. So I’m having a hard time understanding what’s going on.

    Why would it parse some of the ee tags and not others?

    You’ve been very helpful thus far. Thanks a heap.

  • #10 / Oct 09, 2008 3:59pm

    Lisa Wess

    20502 posts

    I’m betting that {my_template_group} is an assigned variable that you’ve picked up somewhere.  But it needs to be declared in the same template or you need to hard-code the template name.  Try replacing {my_template_group} with devbeerg and see if that helps.

  • #11 / Oct 09, 2008 4:05pm

    Dan Lee

    12 posts

    Aha! I used:

    {assign_variable:my_weblog="beer_log"}
    {assign_variable:my_template_group="devbeerg"}

    in the index page at the top so I could use my_template_group throughout, but it wasn’t part of my page_head template. I didn’t know that it needed to be. I put that beast in there and bam! Works great!.

    You’re pretty much amazing. I’d buy you a drink if you lived close. Thanks a heap.

  • #12 / Oct 09, 2008 5:31pm

    Lisa Wess

    20502 posts

    My pleasure, Dan.  Here’s the docs on assigned variables so that you understand how they work. You might note the first few sentences:

    Assigned Variables act as a straight string replacement for use later in the same template.

    Personally, for things like you’re describing, I prefer path.php global variables so that they’re not assigned in several templates. =)

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases