WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: sayf_theone on October 12, 2009, 06:31:10 PM

Title: How to make code snippets for WYSIWG
Post by: sayf_theone on October 12, 2009, 06:31:10 PM
Can anyone tell me please how to make code snippets for WYSIWG take the title and a little of the text.

i have the " Anynews" but its work only with News and not work for WYSIWG.

Please reply as soon as possible.

Thank you all :-)
Title: Re: How to make code snippets for WYSIWG
Post by: crnogorac081 on October 12, 2009, 06:39:21 PM
Could you please specify what exactly you need ? Or little example ?

By the way, there is no title in wysiwyg ... only in news...
Title: Re: How to make code snippets for WYSIWG
Post by: Stefek on October 12, 2009, 06:46:47 PM
Hello Ivan,
he means the title of the whole page, I guess ;-)

KR,
Stefek
Title: Re: How to make code snippets for WYSIWG
Post by: crnogorac081 on October 12, 2009, 07:13:49 PM
He can generate the title with

Code: [Select]
<?php
echo PAGE_TITLE;
?>


or if he wants menu title then

echo MENU_TITLE

But he said also "a little of text.."

Try with this droplet, this is ShowSection droplet from AMASP (little changed for your needs :) )

Code: (txtpiece) [Select]

global $database, $wb;
$sections=explode(",",$section);
shuffle($sections);
$get_content = $database->query("SELECT content FROM ".TABLE_PREFIX."mod_wysiwyg WHERE section_id = '$sections[0]'");
$fetch_content = $get_content->fetchRow();
$content = ($fetch_content['content']);
$wb->preprocess($content);
return substr($content,$txt_start,$txt_lenght).'...';


Name your droplet: txtpiece and try this call:

[[txtpiece?section=51&txt_start=0&txt_lenght=100]]

Where 51 is your sectio number, txt_start is starting point, txt_lenght is how much characters you want to display from starting point..

Example: If your text is: Hello world!  , droplet [[txtpiece?section=51&txt_start=6&txt_lenght=5]] wil display: world...

Just note to input correct section number :)

good luck :)
Title: Re: How to make code snippets for WYSIWG
Post by: Stefek on October 12, 2009, 07:22:41 PM
This is a cool droplet, Ivan.

Thumbsup!

Regards,
Stefek
Title: Re: How to make code snippets for WYSIWG
Post by: crnogorac081 on October 12, 2009, 07:53:50 PM
I just added one line :p

Well see if this is what sayf_theone  needs :)

cheers
Title: Re: How to make code snippets for WYSIWG
Post by: sayf_theone on October 13, 2009, 02:15:55 PM
Thank you very much  :-)

but it don't work

      global $database, $wb;
$sections=explode(",",$section);
shuffle($sections);
$get_content = $database->query("SELECT content FROM ".TABLE_PREFIX."mod_wysiwyg WHERE section_id = '$sections[0]'");
$fetch_content = $get_content->fetchRow();
$content = ($fetch_content['content']);
$wb->preprocess($content);
return substr($content,$txt_start,$txt_lenght).'...';
$a=substr (51,6,5);
echo $a;


nothing displayed :(


what i want to do is :
1- add a new input like "Snap for the Page"  in "Modify Page Settings" .  in the main page i want to put a box that snap or take what i entered in "Snap for the Page"  and show it randomly ( from any page )

2- Input a new Input " page name "  in "Modify Page Settings" and save it in database so i can get it
  like echo PAGE_TITLE
  like echo PAGE_NAME * new


i will be regretful  if you help me.

i know php, but i can't work with the WebsiteBaker's files :(
 
Title: Re: How to make code snippets for WYSIWG
Post by: crnogorac081 on October 13, 2009, 03:08:54 PM
First of all, do not change droplet code !

Just go to backend - pages and see section if of wysiwyg page from which you want to extract part of text..

Then in another wysiwyg section where you want to put this text, insser this doplet:

[[txtpiece?section=1&txt_start=0&txt_lenght=100]]

Just change number 1 with your section id !!! thats all, and dont touch droplet code, jusst copy-paste it..

cheers