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.

Template function with inputs

October 11, 2012 2:00pm

Subscribe [2]
  • #1 / Oct 11, 2012 2:00pm

    billuk

    2 posts

    I have searched for something to perform my desired operation but haven’t found anything.  Please forgive me if I have missed it an kindly point me in the right direction.

    What I am looking for is a function that can define a template with variable within it.

    For example I have a number of static pages that share the same header.  What I would like is to have a template variable such as this in each:

    {my_sites_header title="Contact Us" keywords="contact, communicate,etc" description="Page to contact us"}

    Then somewhere else ‘my_sites_header’ could be defined as eg.

    <html><head><title>{title}</title><meta name=“keyword” content=”{keywords}”> etc.

    So does such an add-on exist or something/some other way of achieving this exist?

    Thanks in advance.

  • #2 / Oct 11, 2012 2:14pm

    mark186282

    290 posts

    If I understand your question correctly… you might just be looking to use embed functionality

    http://ellislab.com/expressionengine/user-guide/templates/embedding.html

    page on my site:

    {embed='/common/header/' title='Contact Page' description='Page to contact us'}
    
    ... contact page details ...


    in the “common” template group (you can call yours anything… we call ours common)

    /common/header/

    <html>
    
    <head>
    <title>{embed:title}</title>
    <meta name="description" content="{embed:description}">

    Note that embedded files can be nested - which can be very powerful for a complex site.

    I hope this helps

  • #3 / Oct 11, 2012 3:39pm

    billuk

    2 posts

    It does help, thanks very much, it was staring me in the face all along!  I have encountered embeds before but it had totally escaped me!

    Thanks again!

  • #4 / Oct 14, 2012 10:43am

    Kevin Smith

    4784 posts

    Thanks for the help here, mark186282! billuk, anything else we can help with?

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

ExpressionEngine News!

#eecms, #events, #releases