WebsiteBaker Community Forum
WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started 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
-
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
-
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...
-
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>";
-
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.
-
Hello Cliff,
try this one:
<?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
-
That is working, but the PAGE_TITLE command does not Show the dash between words, when the page title got more than one word :-(
-
I forgot: THANX so far...
-
I have solved that Problem with your helf ... thanx
but I had to Change the code:
$sUrl = getenv("SERVER_NAME")."".$_SERVER["PHP_SELF"];
return '<div class="fb-comments" data-href="'.$sUrl.'" data-numposts="5" data-colorscheme="light"></div></div>';