- Posts: 4
- Thank you received: 0
How to add a new a new Event View Layout
- SCCtv
- Topic Author
- Offline
- New Member
-
Less
More
11 years 11 months ago #41224
by SCCtv
How to add a new a new Event View Layout was created by SCCtv
We need the component to conditionally use a different Layout when the user looks at Event Details. There's actually more to the conditions, but for the sake of discussion, when the Event is underway or has passed, then the component needs to load my new Layout called "PastEvent" instead of "default". Also, because we use the component on the homepage, whenever a link to the event is clicked, it uses the Itemid for the homepage. I think I understand why this happens (though it's less than ideal), but i'm hoping that the entirety of my question resolves this as well.
I understand that I can modify the Default layout, but the needed PastEvent layout is so very different and relies on quite a few external variables, that it warrants being separate.
Also, when defaulting to the homepage Itemid, we get all the modules, and other Homepage "things" that should not be showing while viewing a single Event. I have a menu item that is for viewing a single Event, and hoped/assumed that the component would find/use that Itemid . I've seen that you can specify a different Itemid in the modules, but I don't see that parameter for the component.
So...
I know there are a number of ways to hack in the Itemid, but the native code for your component is so clean, i don't want to pollute it with my hacking around trying make sure I've forced it everywhere it might be needed. :S
I've looked specifically at these two files, and started to realize that i wanted your expert opinion before hacking around:
route.php (doesn't seem to consider Layout in it's selection logic of the preferred Itemid)
controller.php (I'm not clear if this is where I would specify a task somewhere to trigger something in the switch/case
I understand that I can modify the Default layout, but the needed PastEvent layout is so very different and relies on quite a few external variables, that it warrants being separate.
Also, when defaulting to the homepage Itemid, we get all the modules, and other Homepage "things" that should not be showing while viewing a single Event. I have a menu item that is for viewing a single Event, and hoped/assumed that the component would find/use that Itemid . I've seen that you can specify a different Itemid in the modules, but I don't see that parameter for the component.
So...
- Where/How do I make a code change that will choose the Default or my new PastEvent *layout* based on the event dates
- If the link to the event includes "view=event" and there is a menu item *with* that view, use *that* Itemid instead of the one from the page clicked from (in my case, the home page)
I know there are a number of ways to hack in the Itemid, but the native code for your component is so clean, i don't want to pollute it with my hacking around trying make sure I've forced it everywhere it might be needed. :S
I've looked specifically at these two files, and started to realize that i wanted your expert opinion before hacking around:
route.php (doesn't seem to consider Layout in it's selection logic of the preferred Itemid)
Code:
public static function findItem($needles = null, $itemId = 0)
Code:
function display( )
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
-
11 years 11 months ago #41248
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Re: How to add a new a new Event View Layout
Hi
1=> Not sure what version of the extension you are using, but if you are using latest version (1.6.2), if you have a menu item to link to that event, the event will then use Itemid of that menu item instead of homepage one. So maybe something is not correct here or you are using an old version ?
2=> Regarding the layout, I think the easiest way is edit the code in the the file components/com_eventbooking/views/event/view.html.php, add this code below somewhere in the display method :
if (event is a past event)
{
$this->setLayout('past_event');
}
else
{
$this->setLayout('default');
}
The idea is that the setLayout method of the JViewLegacy will force the extension to use the entered layout instead of default layout. If you know programming, I believe you will understand what I am saying.
Tuan
1=> Not sure what version of the extension you are using, but if you are using latest version (1.6.2), if you have a menu item to link to that event, the event will then use Itemid of that menu item instead of homepage one. So maybe something is not correct here or you are using an old version ?
2=> Regarding the layout, I think the easiest way is edit the code in the the file components/com_eventbooking/views/event/view.html.php, add this code below somewhere in the display method :
if (event is a past event)
{
$this->setLayout('past_event');
}
else
{
$this->setLayout('default');
}
The idea is that the setLayout method of the JViewLegacy will force the extension to use the entered layout instead of default layout. If you know programming, I believe you will understand what I am saying.
Tuan
Please Log in or Create an account to join the conversation.
Moderators: Tuan Pham Ngoc
Support
Documentation
Information
Copyright © 2026 Joomla Extensions by Joomdonation. All Rights Reserved.
joomdonation.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.