By stevenlyons on
I have looked in the docs and done many searches of the forums, but I can't find the answer to thsi question:
How do I alter the HTML (not just the CSS) of the forum topic list page (it's the page that shows all the forum posts)? I assume I call the theme_forum_topic_list function in the template.php file, but nowhere do I see a clear description of how to do this. The PHPTemplate Handbooks do not describe the process. Any guidance would be greatly appreciated.
Comments
theme override
This is just a basic theme override.
Since you are using PHPtemple, just create or add to the file in the theme folder named template.php an override theme function named
phptemplate_forum_topic_listormytheme_forum_topic_list(where mytheme is the name of your theme).see: http://drupal.org/node/11811
This page assumes that you're going to make a template file, but you can also just write the whole function like the original:
http://api.drupal.org/api/4.7/function/theme_forum_topic_list
---
Work: BioRAFT
This works, however attempting the same using _phptemplate_callb
_phptemplate_callback and an individual tpl.php file fails completely ( for all forum overrides, and indeed a custom table theme I attempted ) , can someone explain why. I've always had success using this method and the excellent reference: http://drupal.org/node/11811 for other overrides and custom themeing. I'm using 4.7.4. Very puzzling, is there a simple explanation ?
I like to have things ' tidy ' and don't like the idea of having many long custom functions sat in the template file, it also seems to go against the ' vibe ' of phptemplate engine.
But how to setup the callback?
Thanks, but if I want to make my own forum-topic-list.tpl.php file how do I set up the callback function in template.php? The links you point to don't explain everything. I get the general idea, but how does the array in the callback work? I can see that there are a bunch of variables that need to be included ($tid, $topics, $sortby, $forum_per_page), but what is the syntax in the callback array?
Following the logic of the original referenced file I used this
for the main forum listing, but it's obviously wrong as the forum table comes up blank:
function phptemplate_forum_list($forums, $parents, $tid) {
return _phptemplate_callback('forum_list', array('forums' => $forums, 'parents' => $parents, 'tid' => $tid));
}
So I'd be grateful to know too !
Yes I just tried the same for the topics list...
...and got a blank page as well.
One other question: how does one determine what HTML is being rendered by that function (Like where are the table tags?). The function is using a bunch of PHP objects--is there reference material on this??
API reference:
API reference: http://api.drupal.org/
theme('pager') -> theme_pager() as the default implementation:
http://api.drupal.org/api/4.7/function/theme_pager
http://api.drupal.org/api/4.7/function/theme_table
see also:
http://api.drupal.org/api/4.7/function/theme
---
Work: BioRAFT
How to use the API information?
How do I make changes to only the table that is generated for the forum_topic_list?
Theme the whole forum
Theme the whole forum function as we've been discussing and change the array/parameters passed into theme('table').
---
Work: BioRAFT
it's easier not to make a
it's easier not to make a callback- just put the function above in your template.php file and work with it there
---
Work: BioRAFT
Doesn't Work. Putting that function in template.php...
Causes PHP errors.
hhhm, it shouldn't unless
hhhm, it shouldn't unless PHPtemplate is already defining that function or unless there's a typo.
Do you have other functions in template.php? If it's a new file, but sure to put a PHP tag:
<?phpat the beginning of the file.---
Work: BioRAFT
php tag only at beginning of template.php?
No php tag at the end of the code? Maybe that's the problem.
no ending tag is needed-
no ending tag is needed- better to leave it off.
---
Work: BioRAFT
Check you are using the right one for your version
just copy it from the forum.module for your version.
Correct Version still breaks it
PHP error: cannot redeclare theme_forum_topic_list()
Change the title of the function
add your theme name. As in:
phptemplate_forum_topic_list
You need to rename it as
You need to rename it as above to
phptemplate_forum_topic_list.---
Work: BioRAFT
OK that works.
Thanks for all the help.
Still can't figure out how to modify the table HTML
I have looked at the API docs for theme_table and it appears that it controls all the tables in the site?
How would I modify it so that the table only changes on the Forum topic list page?
Here it is.
For those of struggling with this stuff, I finally figured it out (no thanks to the documentation which is really just a list of the functions in Drupal...not helpful at all).
Once you have the template.tpl.php file working, here's what you can do to add IDs to the table and th tags: