Can someone enlighten me on the use of MENU-BAR and SUB-MENU icons in modules?
Can an icon in the system images directory be used for a SUB-MENU item?
Relationship of large and small icons with system directory structure ( where system expects to find large and small icons )?
What are the differences in a MENU BAR item and a SUB MENU item?
What are the specs for large and small icons?
I have observed that the LARGE icons, used in the menu bar, are located in the system images directory, while sub-menu item SMALL icons are located in the image directory of the module.
The following PSEUDO code is from 'Research Assistant' the second sub menu item:
1 $submenu = new Menu($pgv_lang, module.php?mod=research_assistant&action=addtask);
2 if the ICON is located in the system images directory
3 add the ICON to the SUB-MENU
4 else add the ICON found found at (modules/research_assistant/images/add_task.gif) to the SUBMENU
After copying the icon file to the system images directory and the images\small directory, the file in the system images directories is not used and the local file (located in the module's images directory) is still used.
I have echo'd the path and file names used and they are pointing to the proper directory and file. but the local file is used.
The nuts and bolts of the observation is: SUB-MENU ICONS cannot be accessed outside the module's images directory.
Thanks in advance for any enlightenment.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problem is a module's sub-menu item does not use an ICON file outside of the modules image directory.
The ICON images are accessed similar to a language file pointer with an additional parameter indicating Large/Small. I assume the Large parameter uses the system images directory and the Small parameter uses the system images/small.
The following lines are the pertinent lines:
The Module menu.php
1 if(!empty($PGV_IMAGES))
2 $submenu->addIcon("{$PGV_IMAGE_DIR}/{$PGV_IMAGES}");
The theme.php file in the theme directory identifies the file name as follows: (I am using the Cloudy Theme)
3 $PGV_IMAGES = "add_task.gif"; (This line was added to the file to experiment with ICONS for SUB-MENUs)
After copying the file, 'add_task.gif' from the module images directory, to the system images directory and also the system images/small directory, there are now three copies of the same file with the same name in three directories.
I added code to the menu.php file to identify the results of the IF-THEN statement using two echo statements.
I then changed the large parameter, in lines 1,2 & 3 above, to small and reloaded the welcome page. Indications were as follows:
Using image from systems images directory.
Top menu item ICON on the menu bar is replaced by the words 'Research Assistant'.
The ICON for sub-menu 'Add Task' does not show. (Icons for My Tasks and View Folders are shown)
There are two problems:
The disappearing Menu Bar ICON is caused by a typo in the 'Research Assistant' menu.php file. The IF segment writes the ICON data to the $menu construct, not the $submenu construct. The else segment is correct and writes to the $submenu. Changing $menu to $submenu corrects the problem with the disappearing MENU-BAR Icon. The correction was applied to all of the $submenu items for the Research Assistant.
The remaining problem is when the system finds the correctly identified ICON for a submenu item in the theme.php file, it does not use the file and the ICON does not appear with the submenu item.
Here is a truth table of my observations:
Menu File Theme File IF-ELSE Result
small small IF (system directory, file pointer found) ICON not displayed
large large IF (system directory, file pointer found) ICON not displayed
large small ELSE (module directory) ICON Displayed
small large ELSE (module directory) ICON Displayed
I understand why the module directory is used when the large and small parameters do not match the pointer is not found.
The truth table holds even when the ICON file is not in the system images or images/small directories indicating that the system only looks for a pointer in the theme.php file and not the actual file. When it finds the pointer to the file, why isn't the ICON used for a sub-menu item.
The ICON used for the MENU-BAR is located in the images directory and used.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The nuts and bolts of the observation is: SUB-MENU ICONS cannot be accessed outside the module's images directory.
I think you mean that an icon has to be in the module's images directory. This is probably correct behavior (generally there is no document in PGV that indicates the intent of the programmer). You may have situations where an icon is stored in more than one place. This gives flexibility to use different icons if that is desired.
I suppose, if you're on Linux, you could replace all but one of these files with a hard link. Probably not worth the effort.
hth,
George
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I figured out what the purpose is for the coding and how the menu's work with ICON's. I am writing a utility module and used the research assistant module to see how it is done. Don't like doing something when I don't know what I am doing.
The IF - ELSE construct tests for the existence of the ICON in the Theme images directory, (not the system images directory). If the images are not found there, it defaults to the images in the module's image directory. The large and small parameter do not appear to have any effect on the location of the ICON file. ICONs have to be in the themes images directory, they are not accessed in the images/small directory.
Obviously this is to allow modified ICONs to be used with different themes.
I'll place a bug report to get the $menu, $submenu error corrected for any future release of Research Assistant..
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Just so you know - if there was a menu item to pick - it would NOT be the R/A module. It was written by John's students and is more a hack (IMHO) than a well-conceived and coded module. Also, the menu creation function is dreadfully coded in general with lots of hooks and hacks. The album module is the most recent and best coded in PGV. Use it as an example and you'll be on better ground. -Stephen
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Using PGV 4.2.3
Can someone enlighten me on the use of MENU-BAR and SUB-MENU icons in modules?
Can an icon in the system images directory be used for a SUB-MENU item?
Relationship of large and small icons with system directory structure ( where system expects to find large and small icons )?
What are the differences in a MENU BAR item and a SUB MENU item?
What are the specs for large and small icons?
I have observed that the LARGE icons, used in the menu bar, are located in the system images directory, while sub-menu item SMALL icons are located in the image directory of the module.
The following PSEUDO code is from 'Research Assistant' the second sub menu item:
1 $submenu = new Menu($pgv_lang, module.php?mod=research_assistant&action=addtask);
2 if the ICON is located in the system images directory
3 add the ICON to the SUB-MENU
4 else add the ICON found found at (modules/research_assistant/images/add_task.gif) to the SUBMENU
After copying the icon file to the system images directory and the images\small directory, the file in the system images directories is not used and the local file (located in the module's images directory) is still used.
I have echo'd the path and file names used and they are pointing to the proper directory and file. but the local file is used.
The nuts and bolts of the observation is: SUB-MENU ICONS cannot be accessed outside the module's images directory.
Thanks in advance for any enlightenment.
When testing make sure you're not using a browser cache.
Also confirm that file names are correct.
George
Thanks for your reply.
The problem is a module's sub-menu item does not use an ICON file outside of the modules image directory.
The ICON images are accessed similar to a language file pointer with an additional parameter indicating Large/Small. I assume the Large parameter uses the system images directory and the Small parameter uses the system images/small.
The following lines are the pertinent lines:
The Module menu.php
1 if(!empty($PGV_IMAGES))
2 $submenu->addIcon("{$PGV_IMAGE_DIR}/{$PGV_IMAGES}");
The theme.php file in the theme directory identifies the file name as follows: (I am using the Cloudy Theme)
3 $PGV_IMAGES = "add_task.gif"; (This line was added to the file to experiment with ICONS for SUB-MENUs)
After copying the file, 'add_task.gif' from the module images directory, to the system images directory and also the system images/small directory, there are now three copies of the same file with the same name in three directories.
I added code to the menu.php file to identify the results of the IF-THEN statement using two echo statements.
I then changed the large parameter, in lines 1,2 & 3 above, to small and reloaded the welcome page. Indications were as follows:
Using image from systems images directory.
Top menu item ICON on the menu bar is replaced by the words 'Research Assistant'.
The ICON for sub-menu 'Add Task' does not show. (Icons for My Tasks and View Folders are shown)
There are two problems:
The disappearing Menu Bar ICON is caused by a typo in the 'Research Assistant' menu.php file. The IF segment writes the ICON data to the $menu construct, not the $submenu construct. The else segment is correct and writes to the $submenu. Changing $menu to $submenu corrects the problem with the disappearing MENU-BAR Icon. The correction was applied to all of the $submenu items for the Research Assistant.
The remaining problem is when the system finds the correctly identified ICON for a submenu item in the theme.php file, it does not use the file and the ICON does not appear with the submenu item.
Here is a truth table of my observations:
Menu File Theme File IF-ELSE Result
small small IF (system directory, file pointer found) ICON not displayed
large large IF (system directory, file pointer found) ICON not displayed
large small ELSE (module directory) ICON Displayed
small large ELSE (module directory) ICON Displayed
I understand why the module directory is used when the large and small parameters do not match the pointer is not found.
The truth table holds even when the ICON file is not in the system images or images/small directories indicating that the system only looks for a pointer in the theme.php file and not the actual file. When it finds the pointer to the file, why isn't the ICON used for a sub-menu item.
The ICON used for the MENU-BAR is located in the images directory and used.
Radioace,
In your original post, you said
I think you mean that an icon has to be in the module's images directory. This is probably correct behavior (generally there is no document in PGV that indicates the intent of the programmer). You may have situations where an icon is stored in more than one place. This gives flexibility to use different icons if that is desired.
I suppose, if you're on Linux, you could replace all but one of these files with a hard link. Probably not worth the effort.
hth,
George
Thanks again for your reply:
I figured out what the purpose is for the coding and how the menu's work with ICON's. I am writing a utility module and used the research assistant module to see how it is done. Don't like doing something when I don't know what I am doing.
The IF - ELSE construct tests for the existence of the ICON in the Theme images directory, (not the system images directory). If the images are not found there, it defaults to the images in the module's image directory. The large and small parameter do not appear to have any effect on the location of the ICON file. ICONs have to be in the themes images directory, they are not accessed in the images/small directory.
Obviously this is to allow modified ICONs to be used with different themes.
I'll place a bug report to get the $menu, $submenu error corrected for any future release of Research Assistant..
Just so you know - if there was a menu item to pick - it would NOT be the R/A module. It was written by John's students and is more a hack (IMHO) than a well-conceived and coded module. Also, the menu creation function is dreadfully coded in general with lots of hooks and hacks. The album module is the most recent and best coded in PGV. Use it as an example and you'll be on better ground.
-Stephen