Author Topic: Problem with droplet and echo  (Read 3022 times)

Offline cliff

  • Posts: 58
    • Meine Homepage
Problem with droplet and echo
« 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

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: Problem with droplet and echo
« Reply #1 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
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Offline cliff

  • Posts: 58
    • Meine Homepage
Re: Problem with droplet and echo
« Reply #2 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...


Offline cliff

  • Posts: 58
    • Meine Homepage
Re: Problem with droplet and echo
« Reply #3 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>";

Offline DarkViper

  • Forum administrator
  • *****
  • Posts: 3034
  • Gender: Female
Re: Problem with droplet and echo
« Reply #4 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.
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"You have to take the men as they are… but you can not leave them like that !" :-P
Das tägliche Stoßgebet: Oh Herr, wirf Hirn vom Himmel !

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: Problem with droplet and echo
« Reply #5 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
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

Offline cliff

  • Posts: 58
    • Meine Homepage
Re: Problem with droplet and echo
« Reply #6 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  :-(

Offline cliff

  • Posts: 58
    • Meine Homepage
Re: Problem with droplet and echo
« Reply #7 on: January 27, 2014, 05:06:12 PM »
I forgot: THANX so far...

Offline cliff

  • Posts: 58
    • Meine Homepage
Re: Problem with droplet and echo
« Reply #8 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>';