Hi,
I would like it very much if it was possible to apply different style (or styling) for differents documents types (ie. book, journal article, web article, etc.). I think the APA style give somes indications how to do this, but it is way out of my basic programming skills.
function biblio_style_apa($node, $base= 'biblio', $inline= false) {
$contrib_array = _apa_format_authors($node->biblio_contributors);
$authors = $contrib_array[1];
$output .= '<span class="biblio-authors">'. $authors ."</span> \n";
$output .= (strrpos($authors, '.') == strlen($authors)) ? ". " : " ";
switch ($node->biblio_type) {
case 1 : // Journal Article
case 2 : //Conference Paper
case 3 : // are all
case 4 :
case 5 :
case 6 :
case 7 :
case 8 :
case 9 :
default :
if (isset ($node->biblio_year)) {
$output .= "(". check_plain($node->biblio_year) ."). ";
}
$output .= '<span class="biblio-title-apa">';
$output .= $inline ? l("$node->title", "$base/viewinline/$node->nid") : l("$node->title", "node/$node->nid");
$output .= ". </span> \n";
$output .= !empty ($contrib_array[2]) ? '('. $contrib_array[2] .', Ed.).' : "";
$output .= ($node->biblio_secondary_title) ? '<u>'. check_plain($node->biblio_secondary_title) .'. ' : '<u>';
$output .= ($node->biblio_volume) ? check_plain($node->biblio_volume) . ($node->biblio_issue ? '</u>('. check_plain($node->biblio_issue) .'), ' : ',</u> ') : '</u> ';
// $output .= ($node->biblio_issue) ? '('. check_plain($node->biblio_issue).')' :'';
$output .= ($node->biblio_pages) ? check_plain($node->biblio_pages) .'.' : '';
break; // generic
}
/* if ($node->biblio_date) $output .= ', '. check_plain($node->biblio_date);
if ($node->biblio_number) $output .= ', Number '. check_plain($node->biblio_number);
if ($node->biblio_place_published) $output .= ', '. check_plain($node->biblio_place_published);
*/
return $output;
}
Could someone post a complete exemple?
Thank you!
Denis B.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | biblio_style_custom.txt | 8.46 KB | p0732658 |
| #3 | biblio_custom_css.txt | 3.71 KB | p0732658 |
Comments
Comment #1
rjerome commentedYour right, the framework is there but it hasn't been implemented. Also note, if you are going to do this, the "case" values in the switch are wrong. Those numbers date back to the first version of biblio, the current types start at 100 and go to 130. Basically you would just copy the stuff from the default section to a specific case and modify it accordingly. I may get around to this someday, but I'm now off on vacation for a couple of weeks...
Ron.
Comment #2
p0732658 commentedThank you Ron for pointing me in right direction. Now that I know about the ''case'' values, I might be able to get it to work be myself. I will let you know...
Denis B.
Comment #3
p0732658 commentedHi Ron,
I don't know if Hell is going to freeze over, but I was able to do this by myself!!! Anyway, here is my results in case you think it could be usefult for others...
I've also attache my files (1) biblio_style_custom.inc : change the .txt for .inc and 2) biblio_custom.css : change "_css.txt" to ".css".
Hope this will be usefull to someone
Comment #4
ntripcevich commentedGood work Denis! This is a nice template to start from for others.
Ron mentioned elsewhere that (in the long term) he's looking to move it to a system where we can link into Zotero styles somehow, but this is a great step and various groups can share their specialized biblio styles.
I quickly tried to implement what you've done and I'm getting "No author information available" in the author slots, and also a space around the year ( 2008 ).
I tried to solve these issues and without spending much time at it wasn't able to decode the problem. Maybe you resolved it in a newer version?
Thanks!
Comment #5
p0732658 commentedThank you ntripcevich!
I am very glade you find this helpful... I'm not a very good coder, so I did lost a couple of hairs doing this!!!
I don't know about "No author information available". What document type is it from ? As for the space problems, look for the code
. For exemple :To take out space inside the backets, you would have to remove the
 after the "(" and before ")".I put space their because I write my bibiographies in french. Howerver, the next time I post something I will try to make more "universal".
Denis
Comment #6
jenifertucker commentedHi there
I was looking to customize a style and came across your biblio_stye_custom.css and biblio_custom.css files. I copied them into my biblio folder and then went to Administer > Biblio settings > Styling where I selected "Custom style for biblio (Custom)".
I then took a look at the list of citations and I just got a blank white screen.
Is there something else I need to do than just copy these two files into the directory?
Many thanks.
Jenifer
Comment #7
rjerome commentedHi Jenifer,
I'm not surprised, things have changed greatly since that style was written, hence that style won't work with the current release.
If you want to write your own style (simple), you could start with biblio_style_cse.inc, copy it to something like biblio_style_jt.inc, then edit biblio_style_jt.inc and change ALL instances of "cse" to "jt" (including and most importantly the function names). You should end up with something like the code below...
Basically your just dumping various fields in a particular order with the appropriate punctuation between them. The check_plains are important for security reasons.
This is quite a simple example, if you want to get really fancy, you could modify something like MLA, but I wouldn't recommend starting with that one.
Comment #8
jenifertucker commentedThanks - I had noticed it was quite old, so appreciate your helpful advice.
I copied the 'Chicago' style as it was closer to the format layout I am wanting to achieve inside the biblio directory and replaced all instances as you suggested.
I then tried to go back to the admin pages to select this new style, but got a white screen when I clicked on Administer > Site configuration > Biblio settings.
I also tried to run update.php, but still see the white screen when I try to go to the Biblio settings page.
Just looked at the logs and I've got a server error
[30/May/2009:10:33:39 +0100] "GET /admin/settings/biblio HTTP/1.1" 500 -
I only know the very basics of this side of things, so don't know what has caused this problem when I copied an existing file, renaming it and matching all function name changes, etc.
Jenifer
Comment #9
rjerome commentedThe cause of "White Screen" errors are not likely to show up in the web server logs as they are usually PHP related. If it isn't already enabled, you would need to turn on PHP error logging in the php.ini file and then check the php error logs which I'm sure will lead you to the root of the problem.
Ron.
Comment #10
jenifertucker commentedWhy would a simple copy of an existing .inc file called biblio_style_chicago.inc to biblio_style_jlt.inc with all instances of 'chicago' to 'jlt' cause such a thing? You comment made it sound that's all you needed to do and didn't hint at any side affects.
As I said, I don't have much experience with the server side of things. I'm not sure where the PHP error logs are.
Comment #11
rjerome commentedMy guess is that either there is a syntactical error in the modified file causing PHP to crash OR a memory issue. On more than one occasion I have seen out of memory errors causing this sort of problem. A default PHP/Drupal installation seems to be teetering on the edge of the default PHP memory limit and adding a few more modules or code can sometimes push it over the edge. Enabling the PHP error logs will almost always tell you where the problem lies. Without this information, you (an I) are really just shooting in the dark.
It really isn't hard to turn on error logging (assuming you have administrative access to the server). Just edit the php.ini file and look for the error logging section as follows. This is off my development machine, so I have errors displayed on screen (display_errors = On), you don't want on a production site, but you get immediate feedback and don't have to dig through the logs.
If you make any changes to the php.ini file, you will have to restart your web server for them to take effect.
BTW, what platform are you running on? (Windows, Linux, ...)
Comment #12
jenifertucker commentedThanks for the insight. I'll go and see what I can find.
The rest of the website is running perfectly, the exception just being the biblio settings.
This is what I've got....
MySQL database 5.0.77
PHP 5.2.6
PHP memory limit 32M
Web server Apache/2.2.9 (Fedora)
Comment #13
rjerome commentedThat should be plenty of memory, so it's most likely a syntactical error.
Did you remove the file containing your first attempt at this (based on Comment #3)?
Also note that the file name and function names must match (including case) so if you called the file biblio_sytle_jt.inc then you would have 3 functions called:
the "jt" part being common and the same case.
The code is scanning the directory the module is in for files name biblo_style_*.inc and then trying to call the biblio_style_*_info() function in each one. It's building the name of the "info" function based on the file names found, thus they must match or a undefined function error will occur.
Comment #14
jenifertucker commentedThanks for all your help rjerome. It's all working now after your reminder about removing the first attempt ... something so stupid to have done was to leave the biblio_custom css file there :-/
My apologies for overlooking this, but thanks for replying in the first place.
Am I right that if the biblio module is updated, I'll lose my custom style so need to keep it somewhere safe?
Comment #15
rjerome commentedGlad to hear it working now, as long as it doesn't have the same name as one of the supplied styles, then it will not get overwritten when you upgrade biblio. Now it the interface to the module happens to change then it may stop working, but that's not likely to happen any time soon.
Cheers,
Ron.
Comment #16
rjerome commented