Drupal 7.8.
PHP filter enabled (7.8).
I've got a PHP input format with the PHP evaluator checkbox checked.
I'm using this for a couple of custom blocks. Specifically one of these is to display a Twitter feed using the Twitter Pull module, and the other is to display a Facebook group feed.
The former works fine, and the Twitter Pull module outputs some nice HTML with divs, hyperlinks, spans and whatnot.
However while the Facebook block displays exactly what I want, the HTML output ends up with lots of unwanted BR tags, which makes styling the feed frustrating.
My PHP input format does not have "Convert linebreaks into HTML" checked. This is the first thing I looked for.
Does anyone have any ideas why a simple piece of PHP (outputs a couple of divs, hyperlinks and spans) gets polluted by BR tags?
Comments
Quick bump and a
Quick bump and a rephrase.
How do I stop the php filter from sticking unwanted line breaks into the output?
put a proxy filter in place
For a similar requirement I just parse the echoed stream through a proxy filter using
preg_replaceto strip out html tags.Your block (PHP enabled) then calls the proxy script through an
include_once("proxy.php");.There might be other more elegant drupal ways but this approach is fine for my needs. It is just a simple "tidy up" script.
Thanks for the
Thanks for the suggestion.
I've put a proxy.php in sites/default, calling strip_tags($postdata, '
'); , and used the include_once("proxy.php"); before the closing tag of the appropriate php chunks in my block.
This has made no difference, which I think is more to do with the fact I'm pretty new to Drupal and PHP and am probably misunderstanding something obvious.
This tidying up should really
This tidying up should really be done in the root code ..
but perhaps this might work
Use a curl script to grab the Facebook object code (before it is rendered in drupal).
Note that curl has to be enabled in php.ini.
Write curl output into temp file .. stripping out any unwanted HTML tags
Then include_once("proxy.php") in PHP enabled block (which echos back the tidy code)
Proxy.php reads the temp file and strips out tags.
Typically the path to the included proxy.php might be ..
include_once("sites/all/files/facebook/proxy.php");
...
This php library might offer cleaner code?
http://onlinewebapplication.com/2011/08/login-facebook-twitter-php.html
I'm actually pulling the
I'm actually pulling the facebook data using the graph API, and calling json_decode which is resulting in perfect data to play with. (found http://ranacse05.wordpress.com/2011/02/04/show-facebook-group-wall-on-we... as an example for doing this).
Turns out it was my schoolboy error. I had a few linebreaks between php calls to make the block clearer, and for some reason I cannot get my php input format to ignore line breaks. For now I've just removed all breaks which makes the block difficult to edit but works a treat.
Thanks for your time, sorry for silly error.