Hi
I'd like to show a bloc only if some certain words are on the page.
I was thinking to use the bloc validation code below but it isn't working (no bloc at all, even not it's title)

Can't see what is wrong - help welcome
Best regards
D

<?php
$text = file_get_contents('"http://127.0.0.1".$_SERVER['REQUEST_URI']');
echo (stristr ($text, 'words_i_m_seeking')) ? 'TRUE' : 'FALSE';
?>

Comments

dbourrion’s picture

This way

<?php
$url = "http://127.0.0.1".$_SERVER['REQUEST_URI'] ;
$text = file_get_contents($url);
echo (stristr ($text, 'magasin')) ? 'TRUE' : 'FALSE';
?>

but I always got FALSE in return even when the word "magasin" is in the Drupal page where the bloc is testing

nevets’s picture

It looks like you want 'return' instead of 'echo'.

Side note, the code looks like it will loop indefinitely. Since the block loads the the current page to see if it should display, the page will load the page to see if the block should display which will ...

dbourrion’s picture

Infinite loop, i'm such a fool
Thx
D