WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: cliff on January 27, 2014, 04:36:42 PM

Title: Problem with droplet and echo
Post by: cliff on January 27, 2014, 04:36:42 PM
Hello,

I got a Problem with the php command "echo" in a droplet...

At the Frontpage the content of the echo command will be posed over the <html> in the sourcecode... What's going wrong?

Google and forumsearch doesn't help  :-(

Hopefully you understand my worse english  :mrgreen:

GreetZ
Cliff
Title: Re: Problem with droplet and echo
Post by: Stefek on January 27, 2014, 04:42:03 PM
The use of echo in droplet code is not possible.
Use return instead.

Please post your droplet php code so we can have a look if you need more help.

Stefek
Title: Re: Problem with droplet and echo
Post by: cliff on January 27, 2014, 04:45:14 PM
Hey Stefek,

thanX!

I want to make a droplet for Facebook comments and tested this:

echo "<div id='comment'><div class='fb-comments' data-href='";
return getenv("SERVER_NAME")."".$_SERVER["PHP_SELF"];
echo "' data-numposts='5' data-colorscheme='light'></div></div>";

If I use only the return command, the correct URL will displayed, but with the echo commands it's broken...

Title: Re: Problem with droplet and echo
Post by: cliff on January 27, 2014, 04:46:03 PM
I Forget this one I tested also...

echo "<div id='comment'><div class='fb-comments' data-href='";
echo WB_URL;
echo "/pages/";
echo PAGE_TITLE;
echo PAGE_EXTENSION;
echo "' data-numposts='5' data-colorscheme='light'></div></div>";
Title: Re: Problem with droplet and echo
Post by: DarkViper on January 27, 2014, 04:49:21 PM
By design Droplets does not produce direct output.
A Droplet simply creates a string value which is used then for Search/Replace operations in frontend-output-filter.
Title: Re: Problem with droplet and echo
Post by: Stefek on January 27, 2014, 04:51:47 PM
Hello Cliff,

try this one:

Code: [Select]
<?php

// droplet code
$sUrl WB_URL.'/'.PAGES_DIRECTORY.'/'.PAGE_TITLE.'.'.PAGE_EXTENSION;
return 
'<div id="comment"><div class="fb-comments" data-href="'.$sUrl.'" data-numposts="5" data-colorscheme="light"></div></div>';

Regards,
Stefek
Title: Re: Problem with droplet and echo
Post by: cliff on January 27, 2014, 05:05:04 PM
That is working, but the PAGE_TITLE command does not Show the dash between words, when the page title got more than one word  :-(
Title: Re: Problem with droplet and echo
Post by: cliff on January 27, 2014, 05:06:12 PM
I forgot: THANX so far...
Title: Re: Problem with droplet and echo
Post by: cliff on January 27, 2014, 05:35:10 PM
I have solved that Problem with your helf ... thanx

but I had to Change the code:
Code: [Select]
$sUrl = getenv("SERVER_NAME")."".$_SERVER["PHP_SELF"];
return '<div class="fb-comments" data-href="'.$sUrl.'" data-numposts="5" data-colorscheme="light"></div></div>';