Re: Calling $this->baseurl in a template override?

623 views
Skip to first unread message
Message has been deleted

Chris Davenport

unread,
Dec 13, 2009, 6:24:49 AM12/13/09
to joomla-de...@googlegroups.com
$this in an override is not the same object as $this in a template.

Use JURI::base( true ) instead.

Chris.


2009/12/13 Jason Dreyzehner <jason...@googlemail.com>
Hey everyone,

This is my first go at template overrides, and I'm just trying to
override mod_syndicate with this:

<?php // no direct access
defined('_JEXEC') or die('Restricted access'); ?>

<a href="<?php echo $link ?>"  title="Subscribe to this Pages RSS Feed">
       <img src="<?php echo $this->baseurl ?>/templates/sequoyahlodge/images/
RSS-icon.png" alt="RSS Icon" />
</a>

But it seems like $this->baseurl doesn't work here. Am I missing
something? How can I call for a specific image within my template?

Thanks for your help,
Jason

--

You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-gene...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.



Message has been deleted

Ian MacLennan

unread,
Dec 13, 2009, 11:06:24 PM12/13/09
to joomla-de...@googlegroups.com
I think the main difference would be the module vs component aspect of it, though I could be wrong.  In a component, included from the JView::display method you have a document object, whereas in a module you don't.

Ian

Oli Griffiths

unread,
Dec 14, 2009, 3:49:07 AM12/14/09
to joomla-de...@googlegroups.com
Its quite simple really.

In a template override the file (eg template/html/com_content/article/default.php) is included by the view of the component, thus $this in the context of a template override refers to the instance of JView for that component
The template file (eg templates/mytemplate/index.php) however is included by the Jdocument (or a derivative of eg JDocumentHTML) object and as such, $this in the context of a template refers to the instance of Jdocument

The 2 $this’s are in no way related between a template and a template override, and the template overrides are called when the component is called, quite a while before the template index.php file is included.

Hope this makes sense.

Oli




On 14/12/2009 04:06, "Ian MacLennan" <ian.ma...@joomla.org> wrote:

I think the main difference would be the module vs component aspect of it, though I could be wrong.  In a component, included from the JView::display method you have a document object, whereas in a module you don't.

Ian


On Sun, Dec 13, 2009 at 6:24 AM, Chris Davenport <chris.d...@joomla.org> wrote:
$this in an override is not the same object as $this in a template.

Use JURI::base( true ) instead.

Chris.


2009/12/13 Jason Dreyzehner <jason...@googlemail.com>

Hey everyone,

This is my first go at template overrides, and I'm just trying to
override mod_syndicate with this:

<?php // no direct access
defined('_JEXEC') or die('Restricted access'); ?>

<a href="<?php echo $link ?>"  title="Subscribe to this Pages RSS Feed">
        <img src="<?php echo $this->baseurl ?>/templates/sequoyahlodge/images/
RSS-icon.png" alt="RSS Icon" />
</a>

But it seems like $this->baseurl doesn't work here. Am I missing
something? How can I call for a specific image within my template?

Thanks for your help,
Jason

--

You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.




--
You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
To post to this group, send an email to joomla-de...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/joomla-dev-general?hl=en-GB.

klas berlič

unread,
Dec 14, 2009, 6:39:31 PM12/14/09
to joomla-de...@googlegroups.com
Thank you for making that clear - perhaps template override should be referred to as "view template override" to avoid confusion?

2009/12/14 Oli Griffiths <o...@organic-development.com>



--
------------------------------------------------------------------
http://www.bzzzz.biz  - Creating images
Marketing and web communication agency

http://www.belmondo.si - vacation packages,
travel, flight tickets & hotels

------------------------------------------------------------------

Louis Landry

unread,
Dec 14, 2009, 6:40:57 PM12/14/09
to joomla-de...@googlegroups.com
I tend to refer to them as layout overrides... as that what they technically are.  The layouts are a sub-system of the views.

- Louis

2009/12/14 klas berlič <klas....@gmail.com>



--
Development Coordinator
Joomla! ... because open source matters.
http://www.joomla.org

Ian MacLennan

unread,
Dec 15, 2009, 12:24:23 AM12/15/09
to joomla-de...@googlegroups.com
I thought I remembered seeing some trickery and black magic happening, but it seems there isn't.  $this->baseurl works in layout overrides for components because JView sets that variable in the constructor.

Ian
Reply all
Reply to author
Forward
0 new messages