1

In my custom component, I would like to have multiple slightly different templates for the same view.

Something like

com_things/
...
 - views/
   - thing/
       ...
   - things/
     - tmpl/
         tabs.php
         accordion.php
         default.php
         default.xml
       view.html.php

In this example, the idea is that default template, accordion template and tabs template all use the data prepared in views/things/view.html.php, displaying it in slightly different ways.

The data should be displayed in the right template according to the url from which it's accessed, for example index.php?option=com_things&view=things&tmpl=tabs.

I've been playing with this for a while and looking for documentation, but I'm not being able to implement this feature. Shouldn't be enough to just create the tabs.php and accordion.php file, or am I missing something else?

1 Answer 1

2

I've found the issue, I'm adding it here for future references.

Yes, it's enough to add the additional templates under the directory com_things/views/things/tmpl/.

The problem in the question was that I was using the wrong URL:

it should be

index.php?option=com_things&view=things&layout=tabs

instead of

index.php?option=com_things&view=things&tmpl=tabs .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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