Hi, I din't like to save any changes or any additions to the places where they may not have to stay. Styles are somehow comparable to themes, so why not to save them in the themes folder. By the way I can easily update my module without overwriting my stile.
That's why I have changed a bit the module - in hop you will build this feature in the module. It seems to bee very easy:
1.: add this to line 635
//load styles from theme
$dir = path_to_theme();
$files = array();
if ($dh = opendir($dir)) {
while (($files[] = readdir($dh)) !== false) {
}
closedir($dh);
foreach ($files as $file) {
if (strstr ( $file, 'biblio_style_')) { //find the style files
include_once $dir ."/". $file;
if (function_exists(basename($file, ".inc") .'_info')) {
$styles = array_merge($styles, call_user_func(basename($file, ".inc") .'_info')); //build and array of the short and long names
}
}
}
}
and this to line 1861 (replace the line 1861 by this):
if (file_exists(drupal_get_path('module', 'biblio') . "/biblio_style_$style_name.inc")) {
require_once( drupal_get_path('module', 'biblio') . "/biblio_style_$style_name.inc");
} elseif (file_exists(path_to_theme(). "/biblio_style_$style_name.inc")) {
require_once( path_to_theme() . "/biblio_style_$style_name.inc");
} else {
$style_name='classic';
require_once( drupal_get_path('module', 'biblio') . "/biblio_style_$style_name.inc");
}
I'm not in the developing of the biblio module. Therefor I'm not sure if these changes are really enough. I'd like to get a statement from the active developer(s) about this.
I was thinking about what will happen when s.b. is changing his theme? OK bad luck if the new theme don't have the actual style ;) I'd like to show the classic one ... and maybe give a message out, if the actual selected theme dos not exist.
The problem of my code is, that I am not changing the style variable. May we should pass by reference:
function theme_biblio_list($node, $base='biblio', &$style='classic', $inline=false) {
I'm not sure if &$style='classic' is allowed ... id does not make much sense to me ... therefore I think we have to pass this parameter like &$style='.
The last think I was thinking about, what will happen if a new Version will have some changes in the style? May you need a version for the style. Even better would be to create a template ... I think this would be the best and easiest way for styling, wouldn't it? And it will be a bit more the drupal way.
I append the changes in a patch. But be careful ... this file also includes other fixes (see http://drupal.org/node/232781)
Thank you again for the great module :)
| Comment | File | Size | Author |
|---|---|---|---|
| biblio.module.version_from_20080308.txt | 2.69 KB | osopolar |
Comments
Comment #1
rjerome commentedWhile I agree that "styles" are analogous to theme/templates, I don't think storing "styles" in the theme folder is a great idea since these are really module specific rather than theme specific. They could perhaps be change to Phptemplate .tpl files or maybe more logically, theme functions (and I have been considering this) but I don't see any real benefit to moving them to the theme folder and I do see many potential headaches. For one, a site can have many different (and active) themes so you would have to maintain the styles in multiple locations.
Maybe I'm missing something here, so perhaps you could further explain your rational for this request?
Ron.
(The active developer/maintainer of biblio)
Comment #2
osopolarHow its working at the moment you might be right. I was thinking that a style is like a template ... with variables like $title $author $volume $issue $type $year ... and so on. The only thing is to put some html and styling (css). I'm not sure about this but from this point of view you divide into logic and output. Templates are normally without logic (or with very less if necessary) and lots of people (this includes me) are doing this wrong and are putting an extra logic layer in the template (for that the drupal developers invented the template.php where you put theme-function etc.). At the moment the styles are more or less far away from that ... but I think the Idea was do do something like templates ... and if I need a different one I'll create a different one.
What are you doing with nodes or pages when you change your theme? Aren't you creating a node.tpl or a page.tpl? And you have to do that for each theme. Why not just "node-biblio.tpl"?
If you change the design you change the theme / the template. This does not mean that you have templates in the module directory - but only that ones that where shipped by the module ... and if you want to update, just replace the module folder ... and maybe the template (but this should normally not be necessary ... think about updating drupal and all the time you need to update your themes). That's why you need to define well what is theming and template stuff and what is the modules logic. (http://en.wikipedia.org/wiki/Model-view-controller).
Have a nice day!
Comment #3
bekasu commentedMarking issue closed.