T3 Community Discussion & Support

Let's build the best free Joomla template framework, together!
  1. dilby
  2. General Discussion
  3. Thursday, 03 July 2014
  4.  Subscribe via email
Hi all - I'm looking for the best way to add custom settings options to the T3 template manager that is upgrade-proof.

For example, under the 'theme' option you can edit the site name, the logo, the slogan etc. I can hardcode some more options in here, but how upgrade friendly is it?
Is there a better way to do it that straight hardcoding? Any examples of people doing it before?

Thanks!
Comment
There are no comments made yet.
Accepted Answer
Accepted Answer Pending Moderation
0
Votes
Undo
Hi

1. Please open the template xml file - templateDetails.xml then add the parameters. Here is a sample (in JA Playmag template):

<config>
<fields name="params" addfieldpath="/plugins/system/t3/includes/depend">

<!-- Sample for add or disable template parameters -->
<!--fieldset name="menu_params" label="T3_PARAMS_MEGAMENU">
<field name="group_disable" type="t3depend" function="@group">
<option for="menu_as_bg" value="no">menu_as_bg</option>
</field>
</fieldset-->
<fieldset name="template_params" label="TPL_PARAMS_TEMPLATES_CONFIG" description="TPL_PARAMS_TEMPLATES_CONFIG_DESC">
<field type="t3depend" function="@legend" label="T3_FEATURE_LAYOUT_CONFIG"
description="T3_FEATURE_LAYOUT_CONFIG_DESC"/>
<field
name="feature_layout"
type="list"
global="1"
multiple="true"
label="TPL_FEATURE_LAYOUT"
description="TPL_FEATURE_LAYOUT_DESC">
<option value="grid">TPLJGRID</option>
<option value="small-list">TPLJSMALLLIST</option>
<option value="big-list">TPLJBIGLIST</option>
</field>
<field
name="feature_layout_first"
type="list"
global="1"
label="TPL_FEATURE_LAYOUT_FIRST"
description="TPL_FEATURE_LAYOUT_FIRST_DES">
<option value="grid">TPLJGRID</option>
<option value="small-list">TPLJSMALLLIST</option>
<option value="big-list">TPLJBIGLIST</option>
</field>
<field type="t3depend" function="@legend" label="T3_BACKGROUND_CONFIG"
description="T3_BACKGROUND_CONFIG_DESC"/>
<field name="background1" type="t3media" default=""
label="T3_BACKGROUND_IMAGES_1"
description="T3_BACKGROUND_IMAGES_1_DESC"/>
<field name="background2" type="t3media" default=""
label="T3_BACKGROUND_IMAGES_2"
description="T3_BACKGROUND_IMAGES_2_DESC"/>
<field name="background3" type="t3media" default=""
label="T3_BACKGROUND_IMAGES_3"
description="T3_BACKGROUND_IMAGES_3_DESC"/>
</fieldset>

</fields>
</config>


2. Call the params

You can call it for template or module, it's up to you. For example, I will add to the file: templates/ja_playmag/tpls/default.php

$tplParams = JFactory::getApplication()->getTemplate(true)->params;
$background = array();

$background1 = $tplParams->get('background1','');
if($background1) array_push($background,$background1);

$background2 = $tplParams->get('background2','');
if($background2) array_push($background,$background2);

$background3 = $tplParams->get('background3','');
if($background3) array_push($background,$background3);



Please check attached image to see how the params are added to the template manager.

Gardner
Attachments (1)
Comment
There are no comments made yet.
  1. more than a month ago
  2. General Discussion
  3. # Permalink
Accepted Answer Pending Moderation
0
Votes
Undo
Thanks so much for your reply, that's made perfect sense so far.

Please forgive my ignorance, but you gotta start somewhere and I'm learning slowly!

I'd like to add a very simple few fields - for example, a twitter icon that has a dynamic link that's set in the parameters.

So for the templatedetails.xml I've added:

<field name="Twitter" type="text" default="" label="Twitter" description="Twitter"/>


But I'm not quite sure what to add to the default.php template file for this.

I'd like to them add it to the design of the template using something like:

<a href="/<?php echo $TwitterURL ?>"><i class="fa fa-twitter-square"></i></a>


But in the logic of the php make this only appear if the field is filled in.

Does this make sense? Hope so and thanks so much for your help!
Comment
There are no comments made yet.
  1. more than a month ago
  2. General Discussion
  3. # 1
Accepted Answer Pending Moderation
0
Votes
Undo
Hi Dilby,

Please try to add the code
<?php 
$tplParams = JFactory::getApplication()->getTemplate(true)->params;
$TwitterURL = $tplParams->get('Twitter','');
?>


Before the code:
<a href="/<?php echo $TwitterURL ?>"><i class="fa fa-twitter-square"></i></a>


Hope it helps.

Gardner.
Comment
There are no comments made yet.
  1. more than a month ago
  2. General Discussion
  3. # 2
Accepted Answer Pending Moderation
0
Votes
Undo
Hi - thanks so much!

That's working fine, but how do I put a conditional there that it only shows if the field is filled in in the config?

Thanks!!
Comment
There are no comments made yet.
  1. more than a month ago
  2. General Discussion
  3. # 3
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.