navigate between sections in custom template?

General questions relating to Joomla! 5.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
SocketPup
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 134
Joined: Thu Mar 14, 2024 7:00 am

navigate between sections in custom template?

Post by SocketPup » Fri Mar 29, 2024 3:07 pm

I have setup a functioning index.php for my custom template, and everything looks and work fine. My next step is to add navigation between different pages. So I have created a module for the about-section, added a position for it first in templateDetails.xml (<position>about-section</position>), then in index.php, like this:

Code: Select all

<div id="about-section">
    	<?php if ($this->countModules('about-section')) : ?>
    		<jdoc:include type="modules" name="about-section" />
	<?php endif; ?>
	</div>
Then in admin, I set the module position to the correct one, and also under Menu Assignment unticked the pages where I don't want the module to be displayed. So far all works as planned.

However, I now need to create a new About-link in my main menu. What Menu Item Type do I pick? Is there anything else I need to tick/add as well? I already have a working menu with Home & Articles, but not sure what options to pick for About.

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 31084
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: navigate between sections in custom template?

Post by Per Yngve Berg » Fri Mar 29, 2024 5:26 pm

Normally a Single Article Menu Item Type is used to show the Article that contains the About Infornation.

SocketPup
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 134
Joined: Thu Mar 14, 2024 7:00 am

Re: navigate between sections in custom template?

Post by SocketPup » Fri Mar 29, 2024 6:16 pm

Per Yngve Berg wrote: Fri Mar 29, 2024 5:26 pm Normally a Single Article Menu Item Type is used to show the Article that contains the About Infornation.
Yes, I heard that somewhere else, and so I tried creating an article, added it under a new category (About). Then in my main menu I added a new link, with Menu Item Type: single article. and selected the proper one.

However, when I click the link in my menu on the site, nothing shows.

I have my custom template, and I'd like the article to appear in my <main> section. Do I need to add something there?

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 31084
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: navigate between sections in custom template?

Post by Per Yngve Berg » Fri Mar 29, 2024 6:30 pm

Do you have

<jdoc:include type="component" />

in your template?

https://docs.joomla.org/Jdoc_statements

SocketPup
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 134
Joined: Thu Mar 14, 2024 7:00 am

Re: navigate between sections in custom template?

Post by SocketPup » Sun Mar 31, 2024 12:38 pm

Per Yngve Berg wrote: Fri Mar 29, 2024 6:30 pm Do you have

<jdoc:include type="component" />

in your template?

https://docs.joomla.org/Jdoc_statements
That seems to have worked. But how do I add my custom css classes to one or several of these articles? Do I need to create my own component.php to alter this?

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 31084
Joined: Mon Oct 27, 2008 9:27 pm
Location: Romerike, Norway

Re: navigate between sections in custom template?

Post by Per Yngve Berg » Sun Mar 31, 2024 3:30 pm

You can set classes in the Menu Item.

SocketPup
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 134
Joined: Thu Mar 14, 2024 7:00 am

Re: navigate between sections in custom template?

Post by SocketPup » Sun Mar 31, 2024 5:56 pm

Per Yngve Berg wrote: Sun Mar 31, 2024 3:30 pm You can set classes in the Menu Item.
Thank you. It works in the sense that I can alter background-color, but I can't seem to change css for images and paragraphs (.about-us img {width:300px;}) doesn't result in anything. Do I need to set individual classes for the different markups inside the articles somehow?

SocketPup
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 134
Joined: Thu Mar 14, 2024 7:00 am

Re: navigate between sections in custom template?

Post by SocketPup » Fri Apr 05, 2024 8:41 am

Creating an override for articles seems to have made it to work.


Post Reply

Return to “General Questions/New to Joomla! 5.x”