Advanced search  

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

Pages: [1]   Go Down

Author Topic: Open custom link in a new window.  (Read 4523 times)

0 Members and 1 Guest are viewing this topic.

MetalHellsAngel

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 23
Open custom link in a new window.
« 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
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1609
  • Paul V.
Re: Open custom link in a new window.
« Reply #1 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. 
Logged
Pages: [1]   Go Up
 

Page created in 0.03 seconds with 19 queries.