Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Adding Links  (Read 37807 times)

0 Members and 1 Guest are viewing this topic.

daklay

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 39
    • TT
Adding Links
« on: November 25, 2005, 07:12:19 pm »

I did this in the last version, but, dunno how to do it in this one.
(see attached image)
« Last Edit: November 25, 2005, 07:53:25 pm by donnoman »
Logged

kegobeer

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 4637
  • Beer - it does a body good!
    • The Kazebeer Family Website
Re: Adding Links
« Reply #1 on: November 25, 2005, 07:48:19 pm »

Read the documentation.  You can add a custom link without editing the theme.
Logged
Do not send me a private message unless I ask for one.  Make your post public so everyone can benefit.

There are no stupid questions
But there are a LOT of inquisitive idiots

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Adding Links
« Reply #2 on: November 25, 2005, 07:52:55 pm »

There are several ways of adding links.

If you are just talking about adding one link use the "Custom menu link name" and "Custom menu link URL" options in the config. This will make a single custom button accross every theme that has been properly ugraded to a 1.4 theme.

You can also usurp the href that the "home" button points to in the config by modifing the url for the "URL of your home page" config option. Generally it points to your index.php of coppermine, but it could point anywhere that makes sense, for example the home page of your site, rather than coppermines home page.

For a specific theme:
If you have specified the entire button template ($template_sys_menu or $template_sub_menu) you can add links directly in those.

If you didn't specify a button template, then you can manipulate the links by overriding the button specification:

take the addbutton function and button specifications for the menu you want to modify from themes/sample/theme.php
Code: [Select]
// 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 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','');

and add a few links to it
Code: [Select]
    // 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,'My Button 1','This is the First Custom Button','http://www.disney.com','custom1',$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,'My Button 2','This is the Second Custom Button','http://www.sun.com','custom2',$template_sub_menu_spacer);
    addbutton($sub_menu_buttons,'{SEARCH_LNK}','{SEARCH_TITLE}','{SEARCH_TGT}','search','');

You COULD modify the button specifications in include/themes.inc.php, just remember that any theme that uses thier own $template_sys_menu or $template_sub_menu, it will ignore the button specifications.  At least half of the core themes use thier own templates. (In almost all cases I discourage people from editing themes.inc.php, it is a core component of Coppermine, and shouldn't be messed with lightly.)

If you want to modify the buttons across all of your themes the best option would be to use the plugin system, this is an example of plugin code that modifies the admin buttons, it comes from the minicms plugin at cpg-contrib.org

Code: [Select]

// Add a action
$thisplugin->add_action('page_start','minicms_page_start');

function minicms_add_admin_button($href,$title,$target,$link)
{
  global $template_gallery_admin_menu;

  $new_template=$template_gallery_admin_menu;
  $button=template_extract_block($new_template,'documentation');
  $params = array(
      '{DOCUMENTATION_HREF}' => $href,
      '{DOCUMENTATION_TITLE}' => $title,
      'target="cpg_documentation"' => $target,
      '{DOCUMENTATION_LNK}' => $link,
   );
   $new_button="<!-- BEGIN $link -->".template_eval($button,$params)."<!-- END $link -->\n";
   template_extract_block($template_gallery_admin_menu,'documentation',"<!-- BEGIN documentation -->" . $button . "<!-- END documentation -->\n" . $new_button);
}

function minicms_page_start()
{
  global $CONFIG, $MINICMS, $lang_minicms, $lang_minicms_config, $album, $cat;
  global $HTML_SUBST, $HTML_SUBST_DECODE, $template_minicms, $REFERER, $CURRENT_PIC_DATA;
  require 'plugins/minicms/include/init.inc.php';

  if ($MINICMS['redirect_index_php'] && empty($_SERVER["QUERY_STRING"]) && strstr($_SERVER["PHP_SELF"],'index.php')) {
      header('Location: '.html_entity_decode($MINICMS['redirect_index_php']));
      exit();
  }

  minicms_add_admin_button('index.php?file=minicms/cms_admin',$lang_minicms['admin_title'],'',$lang_minicms['admin_title']);
  minicms_add_admin_button('index.php?file=minicms/cms_config',$lang_minicms['config_title'],'',$lang_minicms['config_title']);
}

In a nutshell minicms_add_admin_button uses the global template variable $template_gallery_admin_menu to extract a button that has already been specified in that menu so that it can get the right styling, saves it to a variable, creates a new button based on the same template, evaluates the template with the custom button info, then adds both the original button that was saved and the new button back into the global template.

I would avoid using the plugin to replace the first or the last button in a template since thier styling can sometimes be different than the buttons in the middle.
« Last Edit: November 27, 2005, 07:57:18 pm by donnoman »
Logged

daklay

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 39
    • TT
Re: Adding Links
« Reply #3 on: November 25, 2005, 09:26:34 pm »

K, i got how to do the first one for the sample theme, but how do I do it for rainy day?
Logged

daklay

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 39
    • TT
Re: Adding Links
« Reply #4 on: November 26, 2005, 02:21:01 am »

...anyone?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Adding Links
« Reply #5 on: November 26, 2005, 04:27:44 am »

in the same way as described above.
Logged

daklay

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 39
    • TT
Re: Adding Links
« Reply #6 on: November 26, 2005, 07:31:17 pm »

Wait...there isn't ANYTHING like that in the theme for rainy day.
Logged

Nibbler

  • Guest
Re: Adding Links
« Reply #7 on: November 26, 2005, 09:13:21 pm »

You copy the code from the sample theme and paste it into the theme you want to modify. Don't modify the sample theme directly.
Logged

daklay

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 39
    • TT
Re: Adding Links
« Reply #8 on: November 26, 2005, 11:14:42 pm »

K...when i do tht, my buttons gets messed up. Isn't there just a way I can add more custom menu button options?
« Last Edit: November 27, 2005, 05:25:16 pm by daklay »
Logged

daklay

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 39
    • TT
Re: Adding Links
« Reply #9 on: November 27, 2005, 03:40:55 am »

...please?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Adding Links
« Reply #10 on: November 27, 2005, 11:20:30 am »

Logged

daklay

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 39
    • TT
Re: Adding Links
« Reply #11 on: November 27, 2005, 05:25:55 pm »

Ya, I thought so.
Well, is there anyway to add more custom button options, or, will there be more in the future?
Logged

donnoman

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 1615
  • From donovanbray.com
    • Donovan Bray
Re: Adding Links
« Reply #12 on: November 27, 2005, 07:39:15 pm »

Theres more than enough ways to add custom buttons to your theme, I can see no reason to provide additional methods.

If you want complete control of the buttons, then override the whole the $template_sys_menu and $template_sub_menu.

See the hardwired or mac_ox_x themes as examples.
Logged

daklay

  • Coppermine novice
  • *
  • Offline Offline
  • Gender: Male
  • Posts: 39
    • TT
Re: Adding Links
« Reply #13 on: November 27, 2005, 07:47:22 pm »

There we go. The hardwired theme is like the last version themes. I can work with this now.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: Adding Links
« Reply #14 on: February 10, 2006, 09:53:51 pm »

Locking this sticky FAQ thread to avoid further individual support cluttering and spoling the thread even further.
Logged
Pages: [1]   Go Up
 

Page created in 0.044 seconds with 22 queries.