Edit Template Styles

Everything to do with Joomla! 3.x templates and templating.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
johnblaine5
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Thu Mar 06, 2014 4:23 pm

Edit Template Styles

Post by johnblaine5 » Fri Jun 01, 2018 5:54 pm

Under Templates, there is a Style page and a Template page. On the styles page I can create various styles of my template "Theme1765" and create a different logo image on each style. My problem is that I am not able to change the link that the logo points to on the styles page. I know how to go into the template index.php page and change the link but it changes the link for every style. How can I customize it so that style "A" logo points to link "A" and style "B" logo points to link "B"?

Using Joomla 3.x

User avatar
starazure
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 142
Joined: Mon Sep 11, 2017 5:18 pm
Location: OH, United States
Contact:

Re: Edit Template Styles

Post by starazure » Fri Jun 01, 2018 8:19 pm

johnblaine5 wrote:Under Templates, there is a Style page and a Template page. On the styles page I can create various styles of my template "Theme1765" and create a different logo image on each style. My problem is that I am not able to change the link that the logo points to on the styles page. I know how to go into the template index.php page and change the link but it changes the link for every style. How can I customize it so that style "A" logo points to link "A" and style "B" logo points to link "B"?

Using Joomla 3.x
I don't know about your theme but this is how to do it..
1) edit template details.xml file. Add a new field of type media .. let's call it "logoimage"
2) edit the index.php file of your template. Echo the param called "logoimage" in the div you want to show your logo.. Looks for other fields in the file to see how it's done or google it.

Now when you set different images for different styles, they will display different images asz logo.
Free fastest Joomla themes - https://starazure.com/joomla-templates

Free useful Joomla extensions - https://starazure.com/extensions

KianWilliam
Joomla! Guru
Joomla! Guru
Posts: 565
Joined: Thu Jan 12, 2017 10:13 am

Re: Edit Template Styles

Post by KianWilliam » Sat Jun 02, 2018 11:39 am

If each logo's style is being employed in a page with a different menu item, just get menu and its related item, then in a switch or if-else condition based on the title of menu item, set the href attribute of the link.
use jQuery to get the attribute href and set it and then you may use addScriptDeclaration() based on the conditions you set via the menuitems in PHP.
Kian William

johnblaine5
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Thu Mar 06, 2014 4:23 pm

Re: Edit Template Styles

Post by johnblaine5 » Mon Jun 04, 2018 5:09 pm

Thank you. I'm not that familiar with writing code. Say that the menu item id is 1, my div id for the logo is "logo" and the link I want that logo image to go to is https://google.com. What would the php if-else code look like?

KianWilliam
Joomla! Guru
Joomla! Guru
Posts: 565
Joined: Thu Jan 12, 2017 10:13 am

Re: Edit Template Styles

Post by KianWilliam » Tue Jun 05, 2018 8:43 am

I just see your message , allright, I make it only through jquery to be faster with less code. you said each link or link container has its own class already set, true?
$content = "
jQuery(document).ready(function(){
if(jQuery(path/to/link or link container).hasClass()=='yourclass')
jQuery(path/to/link).attr('href', 'your url')
else
if(jQuery(path/to/link or link container).hasClass()=='yourotherclass')
jQuery(path/to/link).attr('href', 'yourotherurl')
else
....
});
";
JFactory::getDocument()->addScriptDeclaration($content)

you can use script tag direct or in onload event of window to do all those jquery stuff direct without php joomla functions, If addScriptDeclaration did not work, use <script> tag direct, put it at the end of your page and copy and paste all those jQuery stuff in it.
Good luck
Kian William


Locked

Return to “Templates for Joomla! 3.x”