This forum is for assistance with theme development.

Where does repetitive template PHP code go? template.php or omnibus module?

For my personal weblog, I had PHP code in node-blog.tpl.php and node-aggregator2.tpl.php which was exactly the same. (A modification of the just tags code, if you must know.) Originally I stuck some repetitive code in template.php, but those functions weren't overwriting any themeable functions, they were brand new functions that pulled data out of the database. The other day I heard of the practice of writing your own custom modules for doing repetitive tasks, each individual task being too small for a full module, and now after trying that, I'm wondering what are the best practices around functions that are used in themes? Here's my thinking, but thoughtful corrections are welcome!

  • use template.php only to override "theme underscore" functions, like theme_item_list()/theme('item_list').
  • if you don't think PHP code that doesn't override "theme underscore" functions, it can go directly in the theme
  • if you think PHP code will repeat, or know it does repeat, then move that code into a module, and in that theme, be sure to use if (module_exist('omnibus_module')) or if (function_exists('omnibus_function')) before calling the function
  • if the functions seem like they could be generally useful, and apply only to a certain module, then consider modifying that module directly and submitting the code to the module developer, or at least make the patch public so that others can +1 or -1 it.

Overriding style.css filename in my theme

Hi guys,

A quick question: how can I override my "style.css" filename from within my theme? I want it to be renamed to "style.php"

I can think of two methods:
1) by hacking the template.engine but I dont like the idea of hacking any core files just my theme files.
2) i can hardcode the filename into my theme but I dont like breaking the Drupal convension as well as any duplicates because of print $styles

Both of these are out of the question.

Apply style to Web master comments

I was wondering if anyone knows any way to apply a specific background style to comments replied or posted by the web master.

I tried this but had no luck. Is there an easier way to go about this
<div class="<?php if($name == "Web Master") print "master" ?> <?php print $zebra ?>">

Thank you.

i've designed my own theme.

i've designed my own theme. how can i add login entrance, last comments, recently posted articles, polls, etc. to the left side ? i want to add these by coding.i don't want to work with add/remove block from the admin panel. i want to add codes over my own theme. if you help i'd be glad.

thanks.

Please Help: I can't See Anything

I'm new to Drupal and obviously in over my head. I was experimenting with eliminating the $content region and now I can't see anything. I tried to restore it in my theme but I can't seem to get Drupal to refresh my theme change.

So two questions:

1.) Is there a reason why Drupal isn't picking up my changes (restoring $content) in the theme?

2.) Is there a way to go back to the bluemarine using MySQL? I tried the following but it didn't work:
UPDATE variable SET value='s:10:"bluemarine";' WHERE name = 'theme_default'

TIA,

flanderz

Zebra variable on comments

I just need a little bit of help on applying the zebra affect on my comments.

I have already added to my comment.tpl.php file

<div class="<?php $zebra ?>">  
  ..........
  </div>

and to my style sheet

.comment .even {
	background:url(dashBG.png) repeat top left;
}

.comment odd {
	
}

When I do a view selection source i see the new class inserted but there is no value in it.

Pages

Subscribe with RSS Subscribe to RSS - Theme development