I did my first mini-hack today. I'm just sharing the experience with a specific example.
I don't like the idea that the dashboard News Feed and Security Feed widgets load All news, All the time. So I modified \manager\controllers\default\dashboard widget.modx-news.php and widget.modx-security.php with a simple counter which breaks out of the foreach loop after 3 items. I noticed that someone had done something similar with another feed in
this other forum post. It could also be done like this:
$items = array_slice($rss->items, 0, $num_items);
and then
foreach (array_keys($items) as $key) {}
That's my newbie solution to (a) fixing a minor annoyance, and (b) learning how the dashboard works.
I also noticed that the PieX and FeedX include options for this as well, and that dashboard feeds use modRSSParse, based on MagPie which doesn't seem to have this functionality built-in. (?)
Side note: In my research it "dawned on me" that there is a direct relation between /manager/controllers and /manager/templates, something that I'm sure is obvious to people who work in here all the time but it was new to me. Yippie, very clean and good info for getting a better understanding of the whole environment. I also found the
API pages. I don't know I've missed those but they were somewhat helpful.
Questions:
- I'm thinking that's probably not the best way to make a customization. It will get blown away on the next update. Is there a system of overrides which allows a hack like this to get called instead of the default? Or is the accepted procedure to merge customizations back into the core after each update?
- Is this the kind of thing to submit as a possible patch to core, using a new system parameter rather than hard-coding the limit?
- Would there have been a better way to do this?
- I've been looking for a way to get the original RSS query to return less data so that the limit doesn't need to be set on the already parsed array of items like this. Any ideas?
- Is any part of this data cached anywhere? I'm just trying to improve performance. If the RSS XML, the parsed items, or the rendered data are already saved somewhere, then maybe this solution is overkill?
- Is there a list anywhere of other helpful dashboard widgets that people use?
- I was surprised that when looking at default dashboard widgets that there is no way to tell where the scripts are stored. I mean, you can see the default widgets but none of the properties as set under New Widget. So I had to hunt in the file system to find the scripts. I see the text for the default widgets are in the lexicon as w_*. Apparently these really are hard-coded and site-specific widgets are stored differently?
- Have I missed some documentation describing this part of the environment?
I'm hoping this thread will also help others to understand how this works...
Thanks!