Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Author Topic: Adding button into article form in 1.7RC  (Read 6666 times)

stanislavsky

  • Newbie
  • *
  • Karma: 4
  • Posts: 18
  • Use it or lose it
    • DesignSkill.org
Adding button into article form in 1.7RC
« on: August 11, 2008, 04:20:09 AM »

Hi,
I'm using milkbox (a kind of lightbox) for my portfolio pictures. Unfortunately every time i need to write rel="milkbox" for every link tag.
The question is: how to make a link tag button that already contains this piece of code?   

In other words:
Let's say we have a button called Milkbox. When you click on it it gives you smth like this in a textfield:
Code: [Select]
<a href="" title="" rel="milkbox"></a>
Thanks
« Last Edit: August 11, 2008, 04:25:54 AM by stanislavsky »
Logged
Photoshop CS+     Dreamweaver CS+
Illustrator CS+       Notepad ++
Flash CS+

Ken Dahlin

  • Full Member
  • ***
  • Karma: 30
  • Posts: 139
    • http://www.kendahlin.com/
Re: Adding button into article form in 1.7RC
« Reply #1 on: August 11, 2008, 06:57:27 AM »

Hi,
I'm using milkbox (a kind of lightbox) for my portfolio pictures. Unfortunately every time i need to write rel="milkbox" for every link tag.
The question is: how to make a link tag button that already contains this piece of code?   

In other words:
Let's say we have a button called Milkbox. When you click on it it gives you smth like this in a textfield:
Code: [Select]
<a href="" title="" rel="milkbox"></a>
Thanks


in admin.js look for the block of code that starts with "case 'link':" and ends with "break;" and insert:

Code: [Select]
case 'milkbox':
url = prompt("<?php echo l('js_link1'); ?>", '');
title = prompt("<?php echo l('js_link2'); ?>", '');
if(url != null) {start = '<a href="'+url+'" title="'+title+'" rel="milkbox">'; end = '<\/a>';}
else {start = ''; end = ''; title = '';}
break;

in snews.php find the line that says:

Code: [Select]
   $insert = array('img', 'link', 'include', 'func','intro');

and change it to:

Code: [Select]
   $insert = array('img', 'link', 'include', 'func','intro','milkbox');

finally add these new variables to your language file:

Code: [Select]
   $l['milkbox'] = 'Milkbox';
   $l['milkbox_value'] = 'Milkbox';
Logged

stanislavsky

  • Newbie
  • *
  • Karma: 4
  • Posts: 18
  • Use it or lose it
    • DesignSkill.org
Re: Adding button into article form in 1.7RC
« Reply #2 on: August 11, 2008, 09:09:07 AM »

Many thanks Ken ;)

Actually, i didn't find this line,

Code: [Select]
$insert = array('img', 'link', 'include', 'func','intro');
but solved it in this way:

Code: [Select]
function buttons(){
...
echo '<input type="button" name="link_milkbox" class="button" onclick="tag(\'milkbox\')" value="'.l('milkbox_value').'" title="'.l('milkbox').'" />';
...
}

« Last Edit: August 11, 2008, 09:13:07 AM by stanislavsky »
Logged
Photoshop CS+     Dreamweaver CS+
Illustrator CS+       Notepad ++
Flash CS+

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Adding button into article form in 1.7RC
« Reply #3 on: August 11, 2008, 03:16:52 PM »

Here is an older general reference on Creating new Editor Buttons for sNews versions 1.5 and 1.6  that has gotten 'lost' over in the 1.5 Mods & Addons board. I've just brought it up to date with 1.6 instructions now included.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

stanislavsky

  • Newbie
  • *
  • Karma: 4
  • Posts: 18
  • Use it or lose it
    • DesignSkill.org
Re: Adding button into article form in 1.7RC
« Reply #4 on: August 13, 2008, 01:51:51 PM »

I'm trying to substitute default tag buttons with images like this:

Code: [Select]
echo '<input type="button" name="strong" class="button bold" onclick="tag(\'strong\')" value="'.l('bold_value').'" title="'.l('bold').'" />';to
Code: [Select]
echo '<input type="image" src="folder/bold.gif" name="strong" class="button bold" onclick="tag(\'strong\')" title="'.l('bold').'" />';
but when i click on any replaced image it works like button + submit automatically.

any ideas why it happens?
Logged
Photoshop CS+     Dreamweaver CS+
Illustrator CS+       Notepad ++
Flash CS+

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Adding button into article form in 1.7RC
« Reply #5 on: August 13, 2008, 02:55:41 PM »

If you are working with sNews 1.7RC... take a look in the // ARTICLES FORM function for buttons();. This function-name generates the buttons and the function itself is function buttons() below the // ARTICLES FORM function. This is new in 1.7RC and I am not familiar with how it works because I wasn't involved in programming with 1.7RC.

I just tooks a functioning icon-based button string - that works perfectly fine in my modified 1.6 Editor button-set - and inserted it into the 1.7RC buttons funtion and separately above the function-name in // ARTICLES FORM. In both locations... on mouse-over... it generates a link to index,php?action=process&task=admin_article which... of course... processes as if it was submitted as saved edit... just as you were likely experiencing.

I am also puzzled as to why this occurs and have no answer. Perhaps someone familiar with 1.7RC's functions - like Joost or Equilni or Bakercad - might have a clue to share.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Adding button into article form in 1.7RC
« Reply #6 on: August 13, 2008, 07:44:24 PM »

inputs with type="image" act as submit buttons, that's just what they do.

FWIW... In both 1.5.31 and 1.6... I was able to use icon images for my Editor buttons (ME packages) by structuring them in this "Bold" text button example. The solution (courtesy of Mika) was adding return false; after the onclick="tag(\'strong\'); bit. Unfortunately... return false; doesn't appear to have any effect in 1.7RC.

Code: [Select]
<?php

# Bold text
echo '<input type="image" class="edit_icon" src="'.db(website).''sn_icons/text_bold.gif" alt="'.l('button_bold').'" name="strong" value="strong" onclick="tag(\'strong\'); return false;" />';

?>

Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

stanislavsky

  • Newbie
  • *
  • Karma: 4
  • Posts: 18
  • Use it or lose it
    • DesignSkill.org
Re: Adding button into article form in 1.7RC
« Reply #7 on: August 13, 2008, 07:55:00 PM »

Thank you Bob.

I've already thought about css solution but it's more work. Anyway, if there is no solution better i use this one...  :)
Logged
Photoshop CS+     Dreamweaver CS+
Illustrator CS+       Notepad ++
Flash CS+