1

I am working on Joomla 1.5. I have to override Joomla default template of my component (Virtuemart). It's working fine. But problem is i have to override my template if user is logged in only. I have to check look like this :

$user = JFactory::getUser();
if($user->guest==1){

// Not override my template 

}else{


// Override this template  

}

I know my condition works, but where should I write this condition. And if the condition is wrong then how can i do this?

  • Are you talking about some specific layout of the template or whole template? – Dmitry Rekun Mar 19 '15 at 11:24
  • Some specific ! :) Like com_virtuemart/views/user – Umesh Mar 19 '15 at 11:28
1

What I would personally do is, use 2 sub templates.

So firstly, create your template override for the view that you want to use, and then create 2 new PHP files, so you directory structure will look like this:

tmpl/
   default.php
   default_guest.php
   default_loggedin.php

In your default.php, add the following:

$user = JFactory::getUser();

if ($user->guest == 1)
{
    echo $this->loadTemplate('guest');
}
else
{
    echo $this->loadTemplate('loggedin');
}

Then in your default_loggedin.php add your code for the main template override.

In your default_guest.php, simply copy and paste the code from the default view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.