Allowing more than one custom link in cpg 1.4 Allowing more than one custom link in cpg 1.4
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Allowing more than one custom link in cpg 1.4

Started by falarious, July 06, 2005, 04:29:41 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

falarious

I would love to have about 6 custom links in coppermine. Can it be done?

donnoman

This is ...almost support, but since it shows how to do something brand-new with the template system I'd like to help illustrate how it works.

You can skin this cat several different ways.

For the most straightforward way (read that as brute force)  Look at step 9 in the theme.php instructions included with the documents directory as an example.

Now, that being said theres another method that I would use personally, and that is manipulate the button arrays directly.

copy these sections  out of sample's theme.php into your theme.php



// Creates an array of tokens to be used with function assemble_template_buttons
// this function is used in this file it needs to be declared before being called.
function addbutton(&$menu,$href_lnk,$href_title,$href_tgt,$block_id,$spacer) {
 $menu[]=array($href_lnk,$href_title,$href_tgt,$block_id,$spacer);
}




 // HTML template for template sys_menu buttons
   // {HREF_LNK}{HREF_TITLE}{HREF_TGT}{BLOCK_ID}{SPACER}
   addbutton($sys_menu_buttons,'{HOME_LNK}','{HOME_TITLE}','{HOME_TGT}','home',$template_sys_menu_spacer);
   addbutton($sys_menu_buttons,'{MY_GAL_LNK}','{MY_GAL_TITLE}','{MY_GAL_TGT}','my_gallery',$template_sys_menu_spacer);
   addbutton($sys_menu_buttons,'{MEMBERLIST_LNK}','{MEMBERLIST_TITLE}','{MEMBERLIST_TGT}','allow_memberlist',$template_sys_menu_spacer);
   addbutton($sys_menu_buttons,'{MY_PROF_LNK}','{MY_PROF_TITLE}','{MY_PROF_TGT}','my_profile',$template_sys_menu_spacer);
   addbutton($sys_menu_buttons,'{ADM_MODE_LNK}','{ADM_MODE_TITLE}','{ADM_MODE_TGT}','enter_admin_mode',$template_sys_menu_spacer);
   addbutton($sys_menu_buttons,'{USR_MODE_LNK}','{USR_MODE_TITLE}','{USR_MODE_TGT}','leave_admin_mode',$template_sys_menu_spacer);
   addbutton($sys_menu_buttons,'{UPL_PIC_LNK}','{UPL_PIC_TITLE}','{UPL_PIC_TGT}','upload_pic',$template_sys_menu_spacer);
   addbutton($sys_menu_buttons,'{REGISTER_LNK}','{REGISTER_TITLE}','{REGISTER_TGT}','register',$template_sys_menu_spacer);
   addbutton($sys_menu_buttons,'{FAQ_LNK}','{FAQ_TITLE}','{FAQ_TGT}','faq',$template_sys_menu_spacer);
   addbutton($sys_menu_buttons,'{LOGIN_LNK}','{LOGIN_TITLE}','{LOGIN_TGT}','login','');
   addbutton($sys_menu_buttons,'{LOGOUT_LNK}','{LOGOUT_TITLE}','{LOGOUT_TGT}','logout','');
   // Login and Logout don't have a spacer as only one is shown, and either would be the last option.





 // HTML template for template sub_menu buttons
   // {HREF_LNK}{HREF_TITLE}{HREF_TGT}{BLOCK_ID}{SPACER}

   addbutton($sub_menu_buttons,'{CUSTOM_LNK_LNK}','{CUSTOM_LNK_TITLE}','{CUSTOM_LNK_TGT}','custom_link',$template_sub_menu_spacer);
   addbutton($sub_menu_buttons,'{ALB_LIST_LNK}','{ALB_LIST_TITLE}','{ALB_LIST_TGT}','album_list',$template_sub_menu_spacer);
   addbutton($sub_menu_buttons,'{LASTUP_LNK}','{LASTUP_TITLE}','{LASTUP_TGT}','lastup',$template_sub_menu_spacer);
   addbutton($sub_menu_buttons,'{LASTCOM_LNK}','{LASTCOM_TITLE}','{LASTCOM_TGT}','lastcom',$template_sub_menu_spacer);
   addbutton($sub_menu_buttons,'{TOPN_LNK}','{TOPN_TITLE}','{TOPN_TGT}','topn',$template_sub_menu_spacer);
   addbutton($sub_menu_buttons,'{TOPRATED_LNK}','{TOPRATED_TITLE}','{TOPRATED_TGT}','toprated',$template_sub_menu_spacer);
   addbutton($sub_menu_buttons,'{FAV_LNK}','{FAV_TITLE}','{FAV_TGT}','favpics',$template_sub_menu_spacer);
   addbutton($sub_menu_buttons,'{SEARCH_LNK}','{SEARCH_TITLE}','{SEARCH_TGT}','search','');


Now just use the addbutton function and modify away. The order in which you use addbutton determines the order when the theme is rendered.

This is the format of addbutton($menu,'{HREF_LNK}','{HREF_TITLE}','{HREF_TGT}','BLOCK_ID','{SPACER}')

Such that HREF_LNK is the clickable text, HREF_TITLE is the hover text, HREF_TGT is the href, BLOCK_ID can be anything EXCEPT one thats already used, and spacer should match the format and _menu var you are working with.  Note in the default config spacer its set to null on the last option, you may want that or not, but you need to take that into account when you start adding buttons, it depends entirely on your theme.

A typical $sub_menu_button might be:

addbutton($sub_menu_button,'CPG-Contrib','Coppermine Contrib','http://cpg-contrib.org','cpg-contrib',$template_sub_menu_spacer);


Hope that helps.

birddog

Hello. I apologize if this question sound ignorant, however, perhaps I am misunderstanding you. I added all blocks of the code on the forum to my themes.php. I still have no idea how to add a button. A little help here? Yes... that's right. I must be a moron. nevertheless, I am a noob, and need a little guidence. Thank you in advance for your reply. Perhaps a pre-made php CPGexternal navigation script would be the answer. I reallly don't know

Joachim Müller

no support on the feature requests board. Thread locked.