Sharing template files between several layout

48 views
Skip to first unread message

Christophe Demko

unread,
Oct 30, 2009, 8:35:21 AM10/30/09
to Joomla! CMS Development
I'm actually working on a library of template files. These templates
have to be available for any layout. I propose to name them _*tpl*.php
(note the underscore)

The JView class could load them only if there is not a
*layout*_*tpl*.php file.

For example:

in a template default.php, call echo $this->loadTemplate('title');
in a template form.php, call echo $this->loadTemplate('title');

if there is not a default_title.php template file, load the _title.php
file
if there is not a form_title.php template file, load the _title.php
file

The loadTemplate method of the JView class has to be modified.

I have proposed a patch http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=18560
able to give this functionality

Ch.D

Andrew Eddie

unread,
Nov 4, 2009, 6:13:32 AM11/4/09
to joomla-...@googlegroups.com
I like the idea. Only change I'd make is maybe they could also be
used across all views. Maybe there should be a special folder,
something like /views/_tmpl/ and that holds common/default
sub-layouts.

Anyone else got any thoughts?

Regards,
Andrew Eddie
http://www.theartofjoomla.com - the art of becoming a Joomla developer




2009/10/30 Christophe Demko <chd...@gmail.com>:

Christophe Demko

unread,
Nov 5, 2009, 12:41:55 AM11/5/09
to Joomla! CMS Development
Andre, I agree with your idea (having a _tmpl folder). In the same
spirit, there could be a templates/*template*/html/*component*/_tmpl
folder to hold common/default sub-layouts in a particular template.

On 4 nov, 12:13, Andrew Eddie <mambob...@gmail.com> wrote:
> I like the idea.  Only change I'd make is maybe they could also be
> used across all views.  Maybe there should be a special folder,
> something like /views/_tmpl/ and that holds common/default
> sub-layouts.
>
> Anyone else got any thoughts?
>
> Regards,
> Andrew Eddiehttp://www.theartofjoomla.com- the art of becoming a Joomla developer
>
> 2009/10/30 Christophe Demko <chde...@gmail.com>:
>
>
>
> > I'm actually working on a library of template files. These templates
> > have to be available for any layout. I propose to name them _*tpl*.php
> > (note the underscore)
>
> > The JView class could load them only if there is not a
> > *layout*_*tpl*.php file.
>
> > For example:
>
> > in a template default.php, call echo $this->loadTemplate('title');
> > in a template form.php, call echo $this->loadTemplate('title');
>
> > if there is not a default_title.php template file, load the _title.php
> > file
> > if there is not a form_title.php template file, load the _title.php
> > file
>
> > The loadTemplate method of the JView class has to be modified.
>
> > I have proposed a patchhttp://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEd...

Christophe Demko

unread,
Nov 5, 2009, 12:48:01 AM11/5/09
to Joomla! CMS Development
We could also have a template/_tmpl/ directory for sharing sub-layouts
between all joomla components and a template/*template*/html/_tmpl for
overwriting them in a template.

On 5 nov, 06:41, Christophe Demko <chde...@gmail.com> wrote:
> Andre, I agree with your idea (having a _tmpl folder). In the same
> spirit, there could be a templates/*template*/html/*component*/_tmpl
> folder to hold common/default sub-layouts in a particular template.
>
> On 4 nov, 12:13, Andrew Eddie <mambob...@gmail.com> wrote:
>
> > I like the idea.  Only change I'd make is maybe they could also be
> > used across all views.  Maybe there should be a special folder,
> > something like /views/_tmpl/ and that holds common/default
> > sub-layouts.
>
> > Anyone else got any thoughts?
>
> > Regards,
> > Andrew Eddiehttp://www.theartofjoomla.com-the art of becoming a Joomla developer

Ron Severdia

unread,
Nov 5, 2009, 3:40:51 PM11/5/09
to Joomla! CMS Development
Looks interesting. So, if I understand correctly, is this a global
override folder for all templates? Is this only helpful for people
using more than one template on their site?

Andrew Eddie

unread,
Nov 5, 2009, 4:36:16 PM11/5/09
to joomla-...@googlegroups.com
My gut feeling is that introduces too many layers to check. I think
I'd prefer to keep overrides within each template because you can
easily get cases where styles clash. It's a good thought, but maybe
we proof-test the initial ideas first and see how they work out first.

Regards,
Andrew Eddie
http://www.theartofjoomla.com - the art of becoming a Joomla developer




2009/11/5 Christophe Demko <chd...@gmail.com>:

Amy Stephen

unread,
Nov 5, 2009, 5:37:21 PM11/5/09
to joomla-...@googlegroups.com
I recommend waiting for this improvement, and the data element standardization. This is a string that once you start pulling it, you'll wind up at Joomla! 2.0.

Strategically, I think it would be better to get 1.6 out the door. We are honestly so far beyond 1.6, as it is, we should get those benefits out to users and onto Web servers.

Then, bring on 2.0.

With a 2.0 common content structure supporting all core components and an ability to easily define new data elements (much of which is also already in "1.6"), the MVC "apparatus" can be moved into the core library and encapsulated classes in the Extensions can drive the core Controllers, Models, and Views using parameters settings.  One common set of layouts can be shared across all of these Extensions and overridden, if necessary in the Template.

Once you start applying the DRY philosophy to this code base, it's remarkable how flexible a MVC / Object Oriented structure can get. Many of us are doing these things with our third party Extensions. It's going to be much, much, much better to have that reuse available in core.

Creating an Extension in many cases will no longer require a developer. We can create panel driven Extension creation. It's that close.

Layouts are the tip of the iceburg. To me, dealing with layouts and data element renaming will simply create extra work and will end up slowing the drive to 2.0. The common data model is going to bring clarity to a lot of opportunity to reduce the redundancy in this code base.

I think bigger, better opportunities are soon upon us, and lots of benefit to sharing "1.6" with folks ASAP.

Respect.
Amy

ssnobben

unread,
Nov 6, 2009, 3:25:40 AM11/6/09
to Joomla! CMS Development
How well is Joomla prepared regarding templates for mobile devices
(Iphone et al.)?

Its getting more and more important that have templates that standard
works for mobile devices too.


http://www.testiphone.com/ http://iphonetester.com/

Christophe Demko

unread,
Nov 7, 2009, 4:31:41 AM11/7/09
to Joomla! CMS Development
I agree with the different remarks: we have to think about this
improvement after 1.6.

I just write a small example describing how it could be used:

imagine a _page.php file shared between all Joomla components (located
in templates/_tmpl)

<?php $prefix=func_get_arg(1);?>
<?php $params=func_get_arg(2);?>
<div class="<?php echo $prefix;echo $params->get('pageclass_sfx')?>">
<?php echo $this->loadTemplate('title',$params);?>
<?php echo $this->loadTemplate('content');?>
</div>

and a _title.php file shared between all Joomla components (located in
templates/_tmpl)

<?php $params=func_get_arg(1);?>
<?php if ($params->get('show_page_title', 1): ?>
<h2><?php echo $this->escape($params->get('page_title')); ?></h2>
<?php endif; ?>


a Joomla component (third party or not) could used these sublayout
with 2 files:

default.php:
<?php echo $this->loadTemplate('page','myprefix',$this->params);?>

default_content.php:
content of the component

The div of page and the title are automatically displayed using
_page.php and _title.php


a template designer could overwrite _page.php, _title.php for all
components, for a specific component or for a particular view of a
specific component.

Ch.D

ssnobben

unread,
Nov 10, 2009, 2:26:50 AM11/10/09
to Joomla! CMS Development
There is one commercial 3pd http://extensions.joomla.org/extensions/tools/site-management-tools/8008
Joomla plg solution for Iphone Joomla. I think mobile easy and good
accessibility is very important for Joomla future.

This should be core function to prepare your Joomla for mobile
devices. What you think is this only a template or setting up a sub
page like http:/mobile.site.com?


----------------------- Some thoughts about Joomla
-------------------------------------------
Its great that Joomla core team thinking strategic what, how and why
certain types of core futures should be prioritized to implement and
to revize this continously so Joomla stay focused how to fit in the
future battlefield of satisfying people's needs .

Even that we dont like this changes on our perception of the harder
battlefield that Joomla is a CMS only - new structures for all type of
services will affect Joomla in future - very soon I believe. This type
of demand for easy integrated mobile+webb services is not only about
one service or one application.

Hard facts is to prepare Joomla for competing in future towards
integrated mobile and web services with tough and large (even that we
dont want to ) with competitors like Apple http://www.apple.com/mobileme/,
IBM, HP, Google, Microsoft, Yahoo, Amazon etc..And its not just about
cloud hosting.

They will give this type of mobile+web SaaS services away almost for
free for small companies and private persons. Just see examples how
Apple doing and what is going on with Google and others. In my country
small companies have started to just use Apple Mac and Iphone mobile
services only and have all they want integrated.

So If you can set up and buy anything you want from a Apple
smorgosboard why should you use Joomla for anything? Apple store
already have more than 5.000 app and Joomla 4.500.
http://www.apple.com/webapps/index.html
Reply all
Reply to author
Forward
0 new messages