Problems with my RSS block

Re: Problems with my RSS block

by John Papaioannou -
Number of replies: 12
I really have no time to go over that block, so here's a couple more suggestions:

  1. In the line I gave above, change $USER to $GLOBALS['USER']
  2. Triple check that the input field is in the form

Any help?
In reply to John Papaioannou

Re: Problems with my RSS block

by Marc Dastous -

Unfortunately, that change didn't work either dead

I guess this begs the question, how many changes to Moodle are occuring in the move to 1.5 and 2.0 that are going to "break" the non-standard blocks, mods, etc. that people have been working on or using over the last year?

I guess the documentation for future iterations of Moodle should include a BOLD cautionary statement that indicates blocks and modules may NOT be compatible after an upgrade with the latest stable release?  Maybe one already exists and I missed it?

Just a suggestion.

Marc

In reply to Marc Dastous

Re: Problems with my RSS block

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
The recent changes were fairly dramatic to allow blocks to be used on any page in Moodle and it wasn't possible to maintain backward compatibility without making the code look really confusing.

Jon has promised me that this most recent scheme is now completely perfect and that any blocks written to this new spec will be compatible until 2050. wink wink wink
In reply to Marc Dastous

Re: Problems with my RSS block

by John Papaioannou -
OK Marc, here comes the solution... smile

Unfortunately that block seems to be a little more complicated than strictly necessary (it seems that it wasn't quite clear that on many occasions you can just benefit from the default code base instead of overriding it, I hope that's going to change now with the available docs) and that's why my quick fixes didn't work.

To just get the block working, you need to:

  • Open blocks/rssfeed/block_rssfeed.php
  • Find this code snippet (it's near the beginning) and DELETE ALL OF IT:
    function print_config() {
global $CFG, $THEME;
print_simple_box_start('center', '', $THEME->cellheading);
include($CFG->dirroot.'/blocks/'.$this->name().'/config.php');
print_simple_box_end();
return true;
}
function handle_config($config) {
foreach ($config as $name => $value) {
set_config($name, $value);
}
return true;
}
  • Now, rename blocks/rssfeed/config.php to blocks/rssfeed/config.html
  • After renaming, add the line with $GLOBALS['USER'] as I describe above
This should get everything working!

Also, please do not feel uneasy about deleting that snippet. As long as you rename the config.php file to its "recommended name", Moodle will automatically recognize it. There is no danger of making things worse.

And then there's also the compatibility issue... well, to be frank, if you had upgraded to Moodle 1.5.2 from 1.5, then you wouldn't ever have had this problem, for one (incidentally, it was caused by the security improvements associated with sesskey and not by Blocks changes). I 'm saying this to point out that frankly, the Blocks system which dates back to pre-1.3 was something of a toy project which met with unexpectedly high demand; the sesskey incident is a consequence of that; and that the new Blocks in 1.5 (while breaking compatibility) are indeed much more able to scale and meet future requirements (no more sesskey incidents in the future).

Actually Martin they might last beyond 2050 but I think that by then people will be more interested in faster-than-light travel than in Blocks tongueout
  1.  
In reply to John Papaioannou

Re: Problems with my RSS block

by Marc Dastous -

Jon;

First, thank you for taking the time to help us try to get the block working again.  Unfortunately, these changes caused the entire settings interface to disappear.

I removed the snippet of code you suggested and renamed the config.php to config.html.  However, the form now doesn't get printed sad

I am attaching our block_rssfeed.php to see if I have missed something that you or anyone else can see.

Again, thank you for the continued work in improving Moodle!  I know this is the price we pay for growth, I am just frustrated that I am not understanding the code more after a year blush

Marc

In reply to Marc Dastous

Re: Problems with my RSS block

by John Papaioannou -
OK Marc... we 'll sort this out, don't worry.

Can you take a look and tell me exactly what version of blocks/moodleblock.class.html you have?

Also, try renaming config.html to config_global.html.

Jon
In reply to John Papaioannou

Re: Problems with my RSS block

by Tim Allen -
Was this problem ever sorted out? I have exactly the same problem.

I'm using moodleblock.class.php (not .html, which isn't in there) version 1.14.2.1.

Thanks in advance, smile
Tim.
In reply to Tim Allen

Re: Problems with my RSS block

by Tim Allen -
OK, I solved this problem myself with the following steps. It seems like the second instructions from Jon above were the key (hmm, why didn't that work when I tried it the other day? thoughtful) :

Add the following code after the first line of blocks/rssfeed/config.php:
<?php echo '<input type="hidden" name="sesskey" value="'. $GLOBALS['USER']->sesskey .'">'; ?>
It works whether or not one renames config.php to config.html.

This seems to get it working again - deleting that block of lines from block_rssfeed.php that Jon suggested above isn't necessary (and indeed, it removes the whole block settings interface in the config screen of moodle!).

This is just a "process of elimination" solution - I don't understand the code at all! blush shy

Hope this helps others who have experienced the same problem with this custom block. smile

Tim.
In reply to Tim Allen

Re: Problems with my RSS block

by John Papaioannou -
This seems to get it working again - deleting that block of lines from block_rssfeed.php that Jon suggested above isn't necessary (and indeed, it removes the whole block settings interface in the config screen of moodle!).

Perhaps you deleted the function has_config() too along with print_config() and handle_config(), that would explain the missing config setting.

I 'm very happy to hear that the problem has been solved. That specific block did have several unorthodox coding practices that made things more difficult than they should be. We 're likely to have an "official" RSS block in 1.5 though.

Jon
In reply to John Papaioannou

Re: Problems with my RSS block

by Daryl Hawes -
Folks,
If you are interested in looking at what is coming and prociding your thoughts here are the instructions on installing the new rss block:
1) Download and install moodle 1.5dev on a non-production system
2) Download contrib/blog
3) Copy the contents of contrib/blog/rss/ to moodle/rss
4) Copy the folder contrib/blog/blocks/rss_client to moodle/blocks
5) Visit the admin page
6) Once tables are installed visit the blocks config link in the admin page and manage the rss_client block
7) Visit a page on your site, turn editing on, add an rss client block and configure it
In reply to Tim Allen

Re: Problems with my RSS block

by Marc Dastous -

Yes sir Tim, this did indeed work!

Thank you, now I can add all those requests the teachers had over the last couple of weeks wink

Marc

PS. Jon, hopefully this block that you speak of for 1.5 will be customizable by course.  The only negative feeling I have about this block as it exists, is that the admin has to do the editing.

In reply to Tim Allen

Re: Problems with my RSS block

by Sean S -
I got this installed and running with no problems.. I was just wondering if it would be possible to somehow change the title that appears on the block from Syndicated Feeds to something else as my ESL students for the most part probably won't know what that is.