WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.9 is now available!


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Problem with droplet and echo
  • Print
Pages: [1]   Go Down

Author Topic: Problem with droplet and echo  (Read 9265 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
Logged

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
Logged
"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...

Logged

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>";
Logged

Offline DarkViper

  • Forum administrator
  • *****
  • Posts: 3087
  • 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.
Logged
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"We need education to cope with digitalization - and NOT the digitalization of education.!"

Tägliches 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
Logged
"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  :-(
Logged

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...
Logged

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>';

Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Problem with droplet and echo
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2