Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How do I extract values from $Head

edited November 2010 in Vanilla 2.0 - 2.8
In an attempt to make my site a bit more SEO friendly I would like to extract values from {asset name='Head'} to use elsewhere in the body of the template.

The first problem I have is how do I extract info from {asset name='Head'} ?
As an example, I would like to use the contents of <title> in the body of my document.
a bit "grep'ing" shows me this: Gdn_Format::Text($Title)
Is it relevant ? can I use this variable somewhere else?

that's problem 1.

Problem 2:
Smarty templates .. never really bothered to learn them :) lazy I know.
BUt I've discovered pretty quickly that I can't use php directly in the tpl.
How and what do I do if I want do something simple like <?php echo "some text here" ?> which clearly does not work in a tpl
more specifically I would like to <?php echo Gdn_Format::Text($Title); ?>

Appreciate any help.


  • Options
    well that helped writing some code in my templates .. thanks.

    I still haven't figured out how to get any stuff out of {asset name='Head'}
    I'd like to be able to use the title elsewhere
  • Options
    bump @Mark maybe?
  • Options
    MarkMark Vanilla Staff
    There are *many* ways to skin a cat :)

    First, you don't have to use the smarty version of the template file. You can choose to use a straight-up PHP version. For an example, grab this file and use it instead of your master.tpl: /applications/dashboard/views/default.master.php

    With that, you'll be able to use pure PHP in your master view.

    Second, depending on what you're going for, there are easier ways to get it. For example, the value in the title tag is built using the head module's Title() method. You can get it's value by going $this->Head->Title(); in the master view.

    What other values are you trying to access?
  • Options
    thanks @Mark .. this put me in the right direction

    on to my next question :) about standard="1"
  • Options
    MarkMark Vanilla Staff
    Is that question in this discussion?
  • Options
    Nah mate. Just saying thanks for your help :)
Sign In or Register to comment.