Welcome to Geeklog, Anonymous Sunday, September 01 2024 @ 12:30 am EDT
Geeklog Forums
COM_article consistency hack for theme development
gHack
So, Geeklog is some really nicely written code. The more I pore through it with my red pen, puzzling out how it works, the more I am impressed by how well-thought out it is. Major kudos to the developers.
One thing that impresses me is how many times I've thought about hacking the code to make it do something new, then found out that a hook already exists to make it do that.
So here's a minor inconsistency that I've found.
I'm working on a theme that sometimes pushes the limits of theme development -- at least, it's significantly different from other themes I've seen in several ways. One thing I want to do is create an article display that's different from the standard article display for use on one page only. Lo and behold, the hook exists for this in COM_article, though it's not mentioned in the comments/documentation for the function. The third parameter, $storytpl, is used to specify a template file for your article text. However, the same is not done for the section that shows the 'Edit' link, the mail/print icons, the 'Read more' link, etc. This template, as well as the featured article templates, are hard-coded into the function.
What I did was to add a fourth parameter, $storybodytpl, to the function definition like so:
(Line 310 in lib-common.php, GL1.3.7)function COM_article( $A, $index='', $storytpl='storytext.thtml' )
becomes:
function COM_article( $A, $index='', $storytpl='storytext.thtml', $storybodytpl='storybodytext.thtml' )
And then line 332:
This takes care of the regular article templates but does not address the featured templates, but those could be addressed in the same way.
In addition, in order to keep from actually changing lib-common, I copied the entire COM_article function out to the functions.php file of my theme, renamed it, made the above changes and now my theme calls this function whenever it needs special article handling.
Cheers,
Chris
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content