Elxis CMS Forum

Support => Elxis 4.x/5.x DEV => Topic started by: jorgebravoc on October 25, 2012, 20:47:11

Title: Articles and Main Menu
Post by: jorgebravoc on October 25, 2012, 20:47:11
Hi,

I have a scenario that needs to be considered. Elxis always allowed to assign a category to a menu item and every article within that category will inherit the menu item. I modified the CSS of the Main Menu in order to see when a menu item is active. When I arrive to the home page (first menu item) I see its menu item colored gray (meaning its active) and there is a module in the Top position assigned only to that specific menu item. When I click in Famous Places I also see its menu item colored gray and the module in the Top position dissapears (as expected, this is great!).

But when I click on an article whether I click it from the home page or its category page I see no menu item colored and the module in top position appears again, this means that the article is not picking up the assignment of its category in the main menu. I believe this must be a bug as Elxis always managed articles very well.

Homepage:        http://localhost:8888/
Category Page:   http://localhost:8888/famous-places/
Article:               http://localhost:8888/famous-places/giza-pyramids.html

As you can see, the URL for the article has the category included but the menu is not recognizing that category and it shows the article as a "floating" article with no menu item assigned and its not like you can assign an article to a menu item, you usually assign a category and articles will just inherit its menu item.

I point at this so it doesn't become a bigger issue in the future.

Thanks
Title: Re: Articles and Main Menu
Post by: jorgebravoc on October 25, 2012, 20:59:48
Here are some pictures:

#1 is the hompeage, first menu item colored (meaning it's active), notice the slider in the top position, list or articles and sidebar below.
Title: Re: Articles and Main Menu
Post by: jorgebravoc on October 25, 2012, 21:01:04
#2 is the category page with a gray menu item (meaning it's active), no slider as the slider was assigned ONLY to the first menu item.
Title: Re: Articles and Main Menu
Post by: jorgebravoc on October 25, 2012, 21:02:34
#3 is the article, notice it doesn't have any menu item colored.... floating.... slider shows up again.
Title: Re: Articles and Main Menu
Post by: Tank on October 26, 2012, 19:49:39
Hi,

You are right. If elx team have a fix for it that will be great.
However, if you expand the first level menu items... to view the second level, you can see that it is selected.

Attached are three pictures that shows my similar issue as well.

elx_mainmenu.jpg - Selected "Locations" first level item shows as selected with greyed background and blue border.

elx_mainmenu_childselect.jpg - "Gallery" second level item of "Locations" is selected, but locations is not highlighted.

elx_mainmenuselect_active - when expanding the first level "Locations" you can see in this picture that "Gallery" is selected by a darker background and underlined text.... which is what I set the css to show for second level active item. However "Locations" is still not show as part of selection.
Title: Re: Articles and Main Menu
Post by: Tank on October 26, 2012, 19:51:03
*attached*elx_mainmenuselect_active - when expanding the first level "Locations" you can see in this picture that "Gallery" is selected by a darker background and underlined text.... which is what I set the css to show for second level active item. However "Locations" is still not show as part of selection.

I had to separate my post due to file size limit. Even after shrinking the image. Bah-humbug~  :D
Title: Re: Articles and Main Menu
Post by: datahell on October 28, 2012, 22:05:07
We did some improvements and fixes related to menus but we haven't yet released an updated version.

The menu generator now inserts the full Elxis URI for content items starting with "content:". If you omit "content:" some menus will not be highlighted.
So, until we release an updated version just edit your menu items and put the "content:" segment in front of them.
For example instead of linking to a category like that: "famous-places/" write the link like that: "content:famous-places/".

Other related fixes and improvements:
- Improvements in library menu.class.php for better detection of current menu item.
- Fix re-ordering of menu items after save.
- Added new PHP constants: ELXIS_CATID and ELXIS_ARTID. These constants are available on content category and article pages and their values are equal to the current category/article.

Notes
Elxis 4.x does not use menu ids (previously known as Itemid) for current menu item detection. It analyses the URL segments instead. This method is not so accurate but has many advantages. Also Elxis 4.x menus work very different in comparison to Elxis 2009.x. If there is no a menu item pointing to the specific page no menu item is highlighted. This is how the included menu module works, a third party's module could work differently...
Categories have internal module positions in Elxis 4.x.
What ever you want to do in Elxis 4.x there is surely more than 1 way to do it. You now think with the 2009.x way of doing things. Elxis 4.x has more options. I will show you a quick example.

This is an alternative method of "limiting" a module to be displayed only in category's with id = 5 (catid = 5) pages.
Assign the module's assigned to the position you want in ALL pages.
Open template's index.php file and write an if statement like that.

Code: [Select]
<?php 
if (defined(&#39;ELXIS_CATID&#39;) && (ELXIS_CATID == 5)) {
     
$eDoc->modules(&#39;positionx&#39;, &#39;none&#39;); 
}
?>

Note: Requires Elxis 4.0 rev1325 or newer.
Title: Re: Articles and Main Menu
Post by: Tank on October 30, 2012, 02:01:30
We did some improvements and fixes related to menus but we haven't yet released an updated version.

Thanks!! You guys are really spending lots of time for this with fast fixes.

What ever you want to do in Elxis 4.x there is surely more than 1 way to do it. You now think with the 2009.x way of doing things. Elxis 4.x has more options. I will show you a quick example.

This is so true. The more we play with Elxis 4.x. we will discover this. Later, with documentation we will surely find the full power of Elxis 4.x :D
Title: Re: Articles and Main Menu
Post by: speck on November 20, 2012, 11:26:42
in template classes i did something like this
Code: [Select]
    private function getParams() {
$elxis = eFactory::getElxis();

if (defined('ELXIS_CATID')){
$this->idimage = 'cat'.CATID.'.jpg';
}
                ............................
                ............................

but not works  :(
$this->idimage results to be an empty string.
maybe i'm wronging something  ???

elxis rev.1364
Title: Re: Articles and Main Menu
Post by: datahell on November 20, 2012, 13:49:42
You use CATID, the correct constant is ELXIS_CATID
PHP constants (https://www.elxis.net/docs/developers/core/php-constants.html) on Elxis docs.
Title: Re: Articles and Main Menu
Post by: speck on November 20, 2012, 14:51:18
nothing not works  :(

Code: [Select]
/***************************/
/* GET TEMPLATE PARAMETERS */
/***************************/   
    private function getParams() {
$elxis = eFactory::getElxis();
$this->process = true;
if ($this->apc == true) {
$data = elxisAPC::fetch('params', 'tplapplestyle');
if ($data !== false) { $this->tplparams = $data; $this->process = false; }
}

if (defined('ELXIS_ARTID')){
$this->idimage = 'art'.ELXIS_ARTID.'.jpg';
} else if (defined('ELXIS_CATID')){
$this->idimage = 'cat'.ELXIS_CATID.'.jpg';
} else {
$this->idimage = 'none_image.jpg';
}
                ..........................................................
                ..........................................................

return always $this->idimage = 'none_image.jpg';  :(
version PHP 5.3.13
apache 2.2.22
Title: Re: Articles and Main Menu
Post by: datahell on November 20, 2012, 18:59:58
Yes, this is because the template gets parsed before the component.
Do this change and it will work as expected in the template:

open includes/libraries/elxis/document.class.php
Go to line 653. Change this:
      $this->parseTemplate();
      $this->renderComponent();
into this:
      $this->renderComponent();
      $this->parseTemplate();

Go to line 700. Change this:
      $this->parseTemplate();
      $this->renderComponent();
into this:
      $this->renderComponent();
      $this->parseTemplate();
Title: Re: Articles and Main Menu
Post by: speck on November 20, 2012, 19:46:16
thanks a lot, for your useful tip

beeing a new template for EDC, i think to eliminate that option or find another solution (maybe get the name of page showed...nut i must try)