Edit core custom template (page.tpl / template.php / theme-settings.php)

How we add more fields in the appearance -> settings -> "my template"

So that the background image shows several titles and other information.

Edit core custom template (page.tpl / template.php / theme-settings.php)

I added the fields in theme-settings.php, but when i am added new they cannot display at frontend. I changed the print code as well in template.php(code below).

for ($i = 0; $i < count($banners); $i++) {         $output .= '{              "image" : "' . file_create_url($banners[$i]['image_path']) . '",             "title" : "' . "<h2>" . fancy_title(t('@image_title', array('@image_title' => t($banners[$i]['image_title'])))) . "</h2>" . '",             "subtitle" : "' . "<h3>" . fancy_title(t('@image_subtitle', array('@image_subtitle' => t($banners[$i]['image_subtitle'])))) . "</h3>" . '",         },';     }    

I tested and if i change 'subtitle' to 'title' i can print that, but not both.

If anyone can give me a hint i would appreciate. Cheers

EDIT

The fields that i need to print, are created in theme-settings.php with this code,

 // Image title $img_form['image_title']       = array(     '#type' => 'textfield',     '#title' => t('Title'),     '#default_value' => $image_data['image_title'] ); // Image SUB title $img_form['image_subtitle']       = array(     '#type' => 'textfield',     '#subtitle' => t('subTitle'),     '#default_value' => $image_data['image_subtitle'] ); 

printed in template.php with this code,

 for ($i = 0; $i < count($banners); $i++) {         $output .= '{              "image" : "' . file_create_url($banners[$i]['image_path']) . '",             "title" : "' . "<h2>" . fancy_title(t('@image_title', array('@image_title' => t($banners[$i]['image_title'])))) . "</h2>" . '",             "subtitle" : "' . "<h3>" . fancy_title(t('@image_subtitle', array('@image_subtitle' => t($banners[$i]['image_subtitle'])))) . "</h3>" . '",         },';     } 

and called in page.tpl.php with this code,

 <?php if (theme_get_setting("slideshowType")=="image") : ?> 

So, the second field created shows in drupal- settings - template, stores the info in the database, but isn't printed correctly in page.tpl

If any more info is needed i will provide it.

Ps. I'm new to drupal and PHP.

Replay

If you want to add more items/theme in your home page template, do the following the steps..

  1. Create a new tpl by editing existing page.tpl.php.
  2. Add your fields into new tpl.
  3. Name your new tpl as page--front.tpl.php.
  4. Put your new template in current-theme/templates.

If you want to add more items in your theme options page do it in

hook_form_system_theme_settings_alter()

After reading the answer given, i searched in the code to find how to pass the 2 fields, and after sometime i realized that was the Javascript that was in charge to print the variables in the target ID, and not the PHP

The original that printed the field:

 if (a(vars.slide_caption).length) {
            (api.getField("**title**")) ? a(vars.slide_caption).html(api.getField("**title**")) : a(vars.slide_caption).html("");
        }

To print 2 fields:

 if (a(vars.slide_caption).length) {
            (api.getField("**title**") && api.getField("**subtitle**")) ? a(vars.slide_caption).html(api.getField("**title**") + api.getField("**subtitle**")) : a(vars.slide_caption).html("");
        }

Thank you for your time. Would give +vote, but i don't have permissions. Cheers

Category: 7 Time: 2015-10-15 Views: 1
Tags: theming

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.323 (s). 12 q(s)