Template Naming Convention

236 views
Skip to first unread message

Nick Savov

unread,
Jul 21, 2012, 9:20:18 AM7/21/12
to joomla-...@googlegroups.com
Hi everyone,

Right now, as far as I'm aware, there is not a Template Naming Convention that is reflected and honored by the code.  This results in peculiar bugs popping up because different functions expect different things and validate differently.  For example:

Template Developers also have different expectations and that's why many include spaces within their templateDetails.xml name tag.

In order to properly fix those bugs and prevent such bugs from occurring in the future, a proper naming convention needs to be decided.

I would like to see template developers having an opportunity to name the
template whatever they'd like (with or without spaces, with or without
uppercases, and with or without special characters), so that it actually reads
like a name in the backend and not as though a computer generated it.

I would like to them to be able to use a language key for the name, so that it
can be easily translated into other languages.

With that being said, can we make a new tag called
<displayName></displayName> that will contain the language key and
be used for the backend name?

The folder name convention could then be all lowercase without spaces or
special characters, and the xml name tag would match it, while the xml
displayName tag could be whatever the developer wanted.

Your thoughts? 

Kind regards,
Nick

Matt Thomas

unread,
Jul 21, 2012, 8:58:04 PM7/21/12
to joomla-...@googlegroups.com

Hi Nick,

I agree about improving the way the templateDetails.xml <name> field is handled. In 1.5, we could use "Test Template" in templateDetails.xml, and the template name would be displayed as "Test Template" in the template manager, but it would be converted to lower case and the space parsed (I don't recall if it was changed to a dash or simple removed) for the name of the directory created for the template.

I'd personally like to see the name field run through the same logic as the article title field is when creating the alias as the alias that is created is a valid system path, which is a major implication of the template name.

As template styles can be named whatever you want, and since the name of template itself represents the directory of the template, I'd be opposed to introducing the <displayName> field and allowing language keys. I think this would likely cause quit a bit of confusion as the name of the template should really match the directory. I'd personally rather see how the <name> field is handled to resolve the issue rather than introducing another field in templateDetails.xml.

Thanks for bringing this up!

Best,

Matt

Sent from my phone that uses an open source operating system.

--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To view this discussion on the web, visit https://groups.google.com/d/msg/joomla-dev-cms/-/xfSecO453FgJ.
To post to this group, send an email to joomla-...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-cm...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-cms?hl=en-GB.

Chad Windnagle

unread,
Jul 22, 2012, 12:08:42 PM7/22/12
to joomla-...@googlegroups.com
I wonder I'd we ahold take some cues from how we do thing in other areas and instead use a XML parameter named <alias>. 
--
Follow Me: Facebook LinkedIn Twitter

Matt Thomas

unread,
Jul 22, 2012, 1:41:50 PM7/22/12
to joomla-...@googlegroups.com

Chad,

How would you use this field? Would it introduce the possibility of naming the template, not style, something other than the template's directory name?

Best,

Matt

Sent from my phone that uses an open source operating system.

Chad Windnagle

unread,
Jul 22, 2012, 10:35:07 PM7/22/12
to joomla-...@googlegroups.com
Hi Matt:

I was thinking along the same lines of how we handle content as an example. This should definitely be a relationship to the template directory. 

For instance:

<name>My Great Template</name>
<alias>my_great_template</alias>

There is a bit of a complication with using languages strings for the alias if it is also the directory name. I don't think it would be a good idea to introduce translations of the directory name. For the template name, though, it wouldn't be a problem as long as the <name> param isn't attached to the directory.

Are styles handled in the XML right now at all? I'm not sure they are (I've not seen it, so if you know of an example I'd like to take a peak).

-Chad

Regards,
Chad Windnagle
Fight SOPA

Matt Thomas

unread,
Jul 23, 2012, 5:52:27 AM7/23/12
to joomla-...@googlegroups.com
Hi Chad,

I assume that you would use <alias> as the name of the template directory and <name> as the name displayed in the the template manager? If so, and with wanting to maintain a relationship to the template directory, why not just run <name> through JApplication::stringURLSafe (http://docs.joomla.org/JApplication::stringURLSafe/1.6) for the directory name when installing and call it a day? 

For example, a templates using <name>My Template's Super Cool Name!</name> would be installed at /templates/my-template-s-super-cool-name Would that make sense and satisfy your goal?

From what I understand, template styles exist only in the database as they are essentially a different set of saved parameters.

Best,

Matt Thomas
Founder betweenbrain
Phone: 203.632.9322
Twitter: @betweenbrain

Rouven Weßling

unread,
Jul 23, 2012, 10:29:55 AM7/23/12
to joomla-...@googlegroups.com
Why can't this be done the same way as with other extensions? (Which involves using language files for the display name)

Rouven

Matt Thomas

unread,
Jul 23, 2012, 10:59:06 AM7/23/12
to joomla-...@googlegroups.com
When you put it that way, being consistent with the behavior of the other types of extensions would be a good thing. How would you determine the name of the directory when using a language file?

Best,

Matt Thomas
Founder betweenbrain
Phone: 203.632.9322
Twitter: @betweenbrain




Rouven Weßling

unread,
Jul 23, 2012, 11:02:29 AM7/23/12
to joomla-...@googlegroups.com
You rely on the extension developer not giving you a nonsense name ;)

Rouven

Matt Thomas

unread,
Jul 23, 2012, 11:04:42 AM7/23/12
to joomla-...@googlegroups.com
LOL!

Would it be based on the name in the language file? Basically, like we've discussed and convert that to an URL safe string? 

Best,

Matt Thomas
Founder betweenbrain
Phone: 203.632.9322
Twitter: @betweenbrain




--

Rouven Weßling

unread,
Jul 23, 2012, 11:07:34 AM7/23/12
to joomla-...@googlegroups.com
I'm not sure what you saying. For all other extensions we have naming conventions:

plg_system_sef
mod_languages
com_content

In the case of modules that actually matches the folder name. We than use that name as the key for the translation to show a user friendly name.

Rouven

Matt Thomas

unread,
Jul 23, 2012, 11:19:49 AM7/23/12
to joomla-...@googlegroups.com
I guess that's always been an issue as templates seemed to have always been handled differently.

As of right now, a template's directory can be whatever the developer decides (i.e. my-template-s-super-cool-name) and we don't prefix those directories with the extension type, which I don't think we'd need as they'd always be in the template's directory.

So, if my language string named the template "My Template's Super Cool Name!" would that be converted to "my-template-s-super-cool-name" when creating the directory, or would the developer need to declare that elsewhere?

Hope that makes sense.

Best,

Matt Thomas
Founder betweenbrain
Phone: 203.632.9322
Twitter: @betweenbrain




Chad Windnagle

unread,
Jul 23, 2012, 10:59:35 AM7/23/12
to joomla-...@googlegroups.com
I assume that you would use <alias> as the name of the template directory and <name> as the name displayed in the the template manager? If so, and with wanting to maintain a relationship to the template directory, why not just run <name> through JApplication::stringURLSafe (http://docs.joomla.org/JApplication::stringURLSafe/1.6) for the directory name when installing and call it a day? 

For example, a templates using <name>My Template's Super Cool Name!</name> would be installed at /templates/my-template-s-super-cool-name Would that make sense and satisfy your goal?

Would this accomplish having translated template names? I was thinking along the lines of what Nick mentioned to have translations for the template name (not the directory name). 

If we only had the <name> param to work with, it would need to be able to fit three needs:

1) template name (in template manager)
2) template name translated (in template manager)
3) template directory, cannot be translated (we don't want to reference a different directory just because its a different language)

Something we would have to overcome is knowing when to use stringURLSafe to generate the directory from the <name> field, but what happens when the default language is switched...especially if we are using language strings for the <name> parameter.

Since the language file needs to be able to have different translations for the string for the template manager, using stringURLSafe on the same language constant would result in a different directory name, right?

Regards,
Chad Windnagle
Fight SOPA


Sam Moffatt

unread,
Jul 23, 2012, 12:08:22 PM7/23/12
to joomla-...@googlegroups.com
It should be underscores and I'm not sure if that is still relevant.
Just glancing through the template installer code we have this:
https://github.com/joomla/joomla-platform/blob/master/libraries/joomla/installer/adapters/template.php#L134

So name is a CMD filtered string of the name value in the template and
then the element is the spaces replaced with underscore version of
that. However the CMD filter has already stripped any spaces IIRC:
https://github.com/joomla/joomla-platform/blob/master/libraries/joomla/filter/input.php#L200

Which means I'm not sure what the str_replace line is doing there but
I can't imagine it to be particularly effective.


What Rouven is suggesting is that you call it
tpl_my_templates_super_cool_name and Joomla will put it in a folder
with the same name and then you can write language strings using that
like TPL_MY_TEMPLATES_SUPER_COOL_NAME="My Template's Super Cool
Name!". I believe that the name is already translated in the UI in
many places. If there is somewhere it isn't translated then we'd need
to update that code however I believe that JM was rather thorough.

Cheers,

Sam Moffatt
http://pasamio.id.au
Reply all
Reply to author
Forward
0 new messages