symfony API

AssetHelper Functions

« Back to API menu

action

addon

cache

config

controller

countable

database

debug

exception

filter

generator

helper

i18n

log

request

response

storage

test

user

util

validator

view

You are currently browsing the symfony API for the 1.0 version. Switch to:

AssetHelper.

Function Summary

  • decorate_with($layout)
    Decorates the current template with a given layout.
  • string javascript_path($source, $absolute = false)
    Returns the path to a JavaScript asset.
  • string get_stylesheets()
    Returns <link> tags for all stylesheets configured in view.yml or added to the response object.
  • string include_title()
    Returns the title of the current page according to the response attributes, to be included in the <title> section of a HTML document.
  • string javascript_include_tag(0)
    Returns a <script> include tag per source given as argument.
  • string include_http_metas()
    Returns a set of <meta http-equiv> tags according to the response attributes, to be included in the <head> section of a HTML document.
  • _compute_public_path($source, $dir, $ext, $absolute = false)
  • use_javascript($js, $position = '')
    Adds a javascript to the response object.
  • string image_path($source, $absolute = false)
    Returns the path to an image asset.
  • string include_metas()
    Prints a set of <meta> tags according to the response attributes, to be included in the <head> section of a HTML document.
  • string image_tag($source, $options = array())
    Returns an <img> image tag for the asset given as argument.
  • string stylesheet_path($source, $absolute = false)
    Returns the path to a stylesheet asset.
  • include_stylesheets()
    Prints <link> tags for all stylesheets configured in view.yml or added to the response object.
  • string get_javascripts()
    Returns <script> tags for all javascripts configured in view.yml or added to the response object.
  • include_javascripts()
    Prints <script> tags for all javascripts configured in view.yml or added to the response object.
  • string stylesheet_tag(0, 1)
    Returns a css <link> tag per source given as argument, to be included in the <head> section of a HTML document.
  • use_stylesheet($css, $position = '', $options = array())
    Adds a stylesheet to the response object.
  • string auto_discovery_link_tag($type = 'rss', $url_options = array(), $tag_options = array())
    Returns a <link> tag that browsers and news readers can use to auto-detect a RSS or ATOM feed for the current page, to be included in the <head> section of a HTML document.

Function Details

  • decorate_with ($layout)

    $layout The layout name or path or false to disable the layout

    Decorates the current template with a given layout.

  • (string) javascript_path ($source, $absolute = false)

    $source asset name
    $absolute return absolute path ?

    Returns the path to a JavaScript asset.

    Example:

      echo javascript_path('myscript');
    
    => /js/myscript.js

    Note: The asset name can be supplied as a...

    • full path, like "/my_js/myscript.css"

    • file name, like "myscript.js", that gets expanded to "/js/myscript.js"

    • file name without extension, like "myscript", that gets expanded to "/js/myscript.js"


    returns file path to the JavaScript file

  • (string) get_stylesheets ()

    Returns <link> tags for all stylesheets configured in view.yml or added to the response object.

    You can use this helper to decide the location of stylesheets in pages. By default, if you don't call this helper, symfony will automatically include stylesheets before </head>. Calling this helper disables this behavior.

    returns <link> tags

  • (string) include_title ()

    Returns the title of the current page according to the response attributes, to be included in the &lt;title&gt; section of a HTML document.

    Note: Modify the sfResponse object or the view.yml to modify the title of a page.

    returns page title

  • (string) javascript_include_tag (0)

    0 asset names

    Returns a &lt;script&gt; include tag per source given as argument.

    Examples:

      echo javascript_include_tag('xmlhr');
    
    => <script language=\"JavaScript\" type=\"text/javascript\" src=\"/js/xmlhr.js\"></script>
    echo javascript_include_tag('common.javascript', '/elsewhere/cools');
    => <script language=\"JavaScript\" type=\"text/javascript\" src=\"/js/common.javascript\"></script>
    <script language=\"JavaScript\" type=\"text/javascript\" src=\"/elsewhere/cools.js\"></script>

    returns XHTML compliant <script> tag(s)

  • (string) include_http_metas ()

    Returns a set of &lt;meta http-equiv&gt; tags according to the response attributes, to be included in the &lt;head&gt; section of a HTML document.

    Examples:

      include_http_metas();
    
    => <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />

    Note: Modify the sfResponse object or the view.yml to change, add or remove metas.

    returns XHTML compliant <meta> tag(s)

  • _compute_public_path ($source, $dir, $ext, $absolute = false)

  • use_javascript ($js, $position = &apos;&apos;)

    Adds a javascript to the response object.

  • (string) image_path ($source, $absolute = false)

    $source asset name
    $absolute return absolute path ?

    Returns the path to an image asset.

    Example:

      echo image_path('foobar');
    
    => /images/foobar.png

    Note: The asset name can be supplied as a...

    • full path, like "/my_images/image.gif"

    • file name, like "rss.gif", that gets expanded to "/images/rss.gif"

    • file name without extension, like "logo", that gets expanded to "/images/logo.png"


    returns file path to the image file

  • (string) include_metas ()

    Prints a set of &lt;meta&gt; tags according to the response attributes, to be included in the &lt;head&gt; section of a HTML document.

    Examples:

      include_metas();
    
    => <meta name=\"title\" content=\"symfony - open-source PHP5 web framework\" />
    <meta name=\"robots\" content=\"index, follow\" />
    <meta name=\"description\" content=\"symfony - open-source PHP5 web framework\" />
    <meta name=\"keywords\" content=\"symfony, project, framework, php, php5, open-source, mit, symphony\" />
    <meta name=\"language\" content=\"en\" /><link href=\"/stylesheets/style.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />

    Note: Modify the sfResponse object or the view.yml to change, add or remove metas.

    returns XHTML compliant <meta> tag(s)

  • (string) image_tag ($source, $options = array())

    $source image asset name
    $options additional HTML compliant <img> tag parameters

    Returns an &lt;img&gt; image tag for the asset given as argument.

    Options:


    • 'absolute' - to output absolute file paths, useful for embedded images in emails

    • 'alt' - defaults to the file name part of the asset (capitalized and without the extension)

    • 'size' - Supplied as "XxY", so "30x45" becomes width="30" and height="45"



    Examples:
      echo image_tag('foobar');
    
    => <img src=\"images/foobar.png\" alt=\"Foobar\" />
    echo image_tag('/my_images/image.gif', array('alt' => 'Alternative text', 'size' => '100x200'));
    => <img src=\"/my_images/image.gif\" alt=\"Alternative text\" width=\"100\" height=\"200\" />

    returns XHTML compliant <img> tag

  • (string) stylesheet_path ($source, $absolute = false)

    $source asset name
    $absolute return absolute path ?

    Returns the path to a stylesheet asset.

    Example:

      echo stylesheet_path('style');
    
    => /css/style.css

    Note: The asset name can be supplied as a...

    • full path, like "/my_css/style.css"

    • file name, like "style.css", that gets expanded to "/css/style.css"

    • file name without extension, like "style", that gets expanded to "/css/style.css"


    returns file path to the stylesheet file

  • include_stylesheets ()

    Prints &lt;link&gt; tags for all stylesheets configured in view.yml or added to the response object.

  • (string) get_javascripts ()

    Returns &lt;script&gt; tags for all javascripts configured in view.yml or added to the response object.

    You can use this helper to decide the location of javascripts in pages. By default, if you don't call this helper, symfony will automatically include javascripts before </head>. Calling this helper disables this behavior.

    returns <script> tags

  • include_javascripts ()

    Prints &lt;script&gt; tags for all javascripts configured in view.yml or added to the response object.

  • (string) stylesheet_tag (0, 1)

    0 asset names
    1 additional HTML compliant <link> tag parameters

    Returns a css &lt;link&gt; tag per source given as argument, to be included in the &lt;head&gt; section of a HTML document.

    Options:


    • rel - defaults to 'stylesheet'

    • type - defaults to 'text/css'

    • media - defaults to 'screen'



    Examples:
      echo stylesheet_tag('style');
    
    => <link href=\"/stylesheets/style.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />
    echo stylesheet_tag('style', array('media' => 'all'));
    => <link href=\"/stylesheets/style.css\" media=\"all\" rel=\"stylesheet\" type=\"text/css\" />
    echo stylesheet_tag('random.styles', '/css/stylish');
    => <link href=\"/stylesheets/random.styles\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />
    <link href=\"/css/stylish.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" />

    returns XHTML compliant <link> tag(s)

  • use_stylesheet ($css, $position = &apos;&apos;, $options = array())

    Adds a stylesheet to the response object.

  • (string) auto_discovery_link_tag ($type = &apos;rss&apos;, $url_options = array(), $tag_options = array())

    $type feed type ('rss', 'atom')
    $url_options 'module/action' or '@rule' of the feed
    $tag_options additional HTML compliant <link> tag parameters

    Returns a &lt;link&gt; tag that browsers and news readers can use to auto-detect a RSS or ATOM feed for the current page, to be included in the &lt;head&gt; section of a HTML document.

    Options:


    • rel - defaults to 'alternate'

    • type - defaults to 'application/rss+xml'

    • title - defaults to the feed type in upper case



    Examples:
      echo auto_discovery_link_tag('rss', 'module/feed');
    
    => <link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"http://www.curenthost.com/module/feed\" />
    echo auto_discovery_link_tag('rss', 'module/feed', array('title' => 'My RSS'));
    => <link rel=\"alternate\" type=\"application/rss+xml\" title=\"My RSS\" href=\"http://www.curenthost.com/module/feed\" />

    returns XHTML compliant <link> tag