Browse archivesSearch |
Drupal aggregator theme changeThe challenge today was to cause the external links from the aggregator to open a new window rather than replace the current window. The current geek wisdom as I understand it is that this should not be done, because all browsers have this capability and users may not want this forced on them. On the other hand, some web designers and most sales/marketing types bristle at the thought of somebody leaving their site whether intentional or not. Philosophy aside, that is the technical task at hand, and it is easily accomplished by inserting a target="_blank" attribute in the link. That is, it is easy if you know where to put it ;-) I am impressed with the technical capabilities of Drupal, and how simply and intuitively (for programmers) you can do things once you get the hang of it. In this case, after a couple of jaunts down wrong pathways, I accomplished what I needed to do. A bit of an example is available, along with some API documentation on the Drupal web site. The particular function that I am interested in is available as well. This solution is for the PHPTemplate theme engine, which seems to be the current and future choice for most of the better designed themes. In the theme folder, there is probably already a template.php file, where these changes will be made. The idea is to create a function with a specific name in this file which will automatically override a corresponding function somewhere in the code for the core modules. You don't actually have to change anything in the module code, so the customizations are neatly isolated to the theme files. To override this function, theme_aggregator_page_item($item), I created a function called phptemplate_aggregator_page_item($item) with an exact copy of the function body. About halfway down the function, there is a long line
where I inserted my target attribute to make it work. Very simple in hindsight, but it certainly took some time to find the needed pieces. By Roger Campbell at Oct 21 2005 - 1:10pm | Technical
|
NavigationUser loginSyndicate |