forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 themes/skins/templates => Topic started by: MetalHellsAngel on December 04, 2005, 07:29:31 am

Title: Open custom link in a new window.
Post by: MetalHellsAngel on December 04, 2005, 07:29:31 am
How could I make my custom link open in a new window?

t.y.i.a.
Angel
Title: Re: Open custom link in a new window.
Post by: Paver on December 04, 2005, 05:17:12 pm
Since the devs were careful to avoid code-injection in the Config option, you cannot do it there.

The best thing to do is to create your own theme and modify it to your tastes.  Make a copy of whatever theme you are currently using and start modifying.  (For example, I made a folder "classic-mod".)  You'll be overriding the default sub_menu in theme.php.  If you are using a theme other than "Classic", you might have this already.  If you see a bunch of HTML for the sub_menu, look for
Code: [Select]
<a href="{CUSTOM_LNK_TGT}" and modify this to
Code: [Select]
<a href="{CUSTOM_LNK_TGT}" target="_blank"
If your theme overrides the sub_menu by using addbutton, look for
Code: [Select]
    addbutton($sub_menu_buttons,'{CUSTOM_LNK_LNK}','{CUSTOM_LNK_TITLE}','{CUSTOM_LNK_TGT}','custom_link',$template_sub_menu_spacer);
and modify this to
Code: [Select]
    addbutton($sub_menu_buttons,'{CUSTOM_LNK_LNK}','{CUSTOM_LNK_TITLE}','{CUSTOM_LNK_TGT}" target="_blank','custom_link',$template_sub_menu_spacer);
This is actually an example of code-injection but since you are the admin modifying your own theme.php, I think it's OK.  To avoid code-injection completely (which might be necessary in the future), you'd have to rewrite your sub_menu as all HTML and then do what I said above for the HTML case.

If you are using "Classic", you'll have to copy code from the "sample" theme to override the sub_menu and then do what I said above for the addbutton case.  Copy the code from the line
Code: [Select]
// Creates buttons from a template using an array of tokens
to the line just before
Code: [Select]
// HTML template for gallery admin menu (don't include this last line).  Then comment out the following 4 lines (by putting two slashes at the beginning of each line):
Code: [Select]
  // $params = array('{BUTTONS}' => assemble_template_buttons($template_sys_menu_button,$sys_menu_buttons));
  // $template_sys_menu = template_eval($template_sys_menu,$params);
and
Code: [Select]
  // $params = array('{BUTTONS}' => assemble_template_buttons($template_sub_menu_button,$sub_menu_buttons));
  // $template_sub_menu = template_eval($template_sub_menu,$params);

This overrides both the system_menu and the sub_menu and you can modify at will.