I don't know if there's an issue like mine, I tried to search without results.
I have a block that runs custom php code and it generates a link using the global variables of drupal, the link is composed like:
echo "<a href='" . $base_url . "/" . $requestpath . "?action=read' >";
The block runs well until it is refreshed and it generates, for example, the link http://mysite.com/node/1?action=read
After the refresh the link transforms into http://mysite.com/block_refresh/block/2/action=read
Is it a known bug or is there a workaround?
Comments
Comment #1
tripper54 commentedThe path you're seeing is the page callback to regenerate the block via AJAX. The solution here is to use the 'send path arguments to block' setting:
1. In the block refresh settings for the block, make sure 'Send page path arguments to block' is checked.
2. Your generated link will now have the original path appended to it, eg http://mysite.com/block_refresh/block/2/node/1?action=read
3. Now just cut the block refresh portion of the argument out of $requestpath, like
Note you should really use drupal's l() function to generate links :) https://api.drupal.org/api/drupal/includes%21common.inc/function/l/7
I'll mark this as a documentation task as this stuff should be covered in the README.
Comment #2
smurfxx commentedThank you very much! I didn't think about an str_replace! Now it works very well!!!
Comment #3
tripper54 commentedGlad I could help.