|
View:
New views
16 Messages
—
Rating Filter:
Alert me
|
|
|
tpl.php file questionhello!
maybe someone can help me with a tpl.php file bringing out converted audios. i am no php or programmer or anything, but know a few things - so much to find myself round at least. so i am running this script to convert audios (mp3 to ogg, wav to mp3 etc..) and want to print them out through node-audio.tpl.php. i can see the frame and where the files should be shown, but everything is there, except the files. you can see it here: http://okno.be/vodnik-frog i am using drupal6 with mysql and the audio module. this is my code in node-audio.tpl.php: $convertpath = '/var/www/okno.be/public/sites/default/files/audio_converted/'; $file = $node->audio; $filepath = $file->filepath; $type = explode(".", basename($filepath)); if (file_exists($filepath)) { $output .= l($type['1'], $filepath) . ' : '; } $type = 'mp3'; $filepath = $convertpath . $file->filename . '.' . $type; $downloadpath = 'sites/default/files/audio_converted/' . $file->filename . '.' . $type; if (file_exists($filepath)) { $output .= l($type, $downloadpath) . ' : '; } $type = 'ogg'; $filepath = $convertpath . $file->filename . '.' . $type; $downloadpath = 'sites/default/files/audio_converted/' . $file->filename . '.'. $type; if (file_exists($filepath)) { $output .= l($type, $downloadpath); } $output = theme('fieldset', array('#title' => 'Download:', '#children' => $output)); print $output; i would appreciate any hint or help! b# _______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
Re: tpl.php file questionLooking at your source code it appears your template doesn't output any
html. Check: your content type is "audio", otherwise node-audio won't work. You are working in a template-file this has a different lay-out then a normal php-scriptfile. Maybe you better post your complete node-audio.tpl.php -----Oorspronkelijk bericht----- Van: themes-bounces@... [mailto:themes-bounces@...] Namens barb Verzonden: woensdag 8 april 2009 20:56 Aan: themes@... Onderwerp: [themes] tpl.php file question hello! maybe someone can help me with a tpl.php file bringing out converted audios. i am no php or programmer or anything, but know a few things - so much to find myself round at least. so i am running this script to convert audios (mp3 to ogg, wav to mp3 etc..) and want to print them out through node-audio.tpl.php. i can see the frame and where the files should be shown, but everything is there, except the files. you can see it here: http://okno.be/vodnik-frog i am using drupal6 with mysql and the audio module. this is my code in node-audio.tpl.php: $convertpath = '/var/www/okno.be/public/sites/default/files/audio_converted/'; $file = $node->audio; $filepath = $file->filepath; $type = explode(".", basename($filepath)); if (file_exists($filepath)) { $output .= l($type['1'], $filepath) . ' : '; } $type = 'mp3'; $filepath = $convertpath . $file->filename . '.' . $type; $downloadpath = 'sites/default/files/audio_converted/' . $file->filename . '.' . $type; if (file_exists($filepath)) { $output .= l($type, $downloadpath) . ' : '; } $type = 'ogg'; $filepath = $convertpath . $file->filename . '.' . $type; $downloadpath = 'sites/default/files/audio_converted/' . $file->filename . '.'. $type; if (file_exists($filepath)) { $output .= l($type, $downloadpath); } $output = theme('fieldset', array('#title' => 'Download:', '#children' => $output)); print $output; i would appreciate any hint or help! b# _______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes _______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
Re: tpl.php file questioncau!
thx for the quick reply... > Looking at your source code it appears your template doesn't output any > html. it's handled over the php... - and the 'box' is visible..... (you can check it here at this link: http://okno.be/vodnik-frog ) > Check: your content type is "audio", otherwise node-audio won't work. > You are working in a template-file this has a different lay-out then a > normal php-scriptfile. > Maybe you better post your complete node-audio.tpl.php <?php // $Id: node.tpl.php,v 1.4 2008/09/15 08:11:49 johnalbin Exp $ /** * @file node.tpl.php * * Theme implementation to display a node. * * Available variables: * - $title: the (sanitized) title of the node. * - $content: Node body or teaser depending on $teaser flag. * - $picture: The authors picture of the node output from * theme_user_picture(). * - $date: Formatted creation date (use $created to reformat with * format_date()). * - $links: Themed links like "Read more", "Add new comment", etc. output * from theme_links(). * - $name: Themed username of node author output from theme_user(). * - $node_url: Direct url of the current node. * - $terms: the themed list of taxonomy term links output from theme_links(). * - $submitted: themed submission information output from * theme_node_submitted(). * * Other variables: * - $node: Full node object. Contains data that may not be safe. * - $type: Node type, i.e. story, page, blog, etc. * - $comment_count: Number of comments attached to the node. * - $uid: User ID of the node author. * - $created: Time the node was published formatted in Unix timestamp. * - $zebra: Outputs either "even" or "odd". Useful for zebra striping in * teaser listings. * - $id: Position of the node. Increments each time it's output. * * Node status variables: * - $teaser: Flag for the teaser state. * - $page: Flag for the full page state. * - $promote: Flag for front page promotion state. * - $sticky: Flags for sticky post setting. * - $status: Flag for published status. * - $comment: State of comment settings for the node. * - $readmore: Flags true if the teaser content of the node cannot hold the * main body content. * - $is_front: Flags true when presented in the front page. * - $logged_in: Flags true when the current user is a logged-in member. * - $is_admin: Flags true when the current user is an administrator. * * @see template_preprocess() * @see template_preprocess_node() */ ?> <div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>"><div class="node-inner"> <?php print $picture; ?> <?php if (!$page): ?> <h2 class="title"> <a href="<?php print $node_url; ?>" title="<?php print $title ?>"><?php print $title; ?></a> </h2> <?php endif; ?> <?php if ($unpublished): ?> <div class="unpublished"><?php print t('Unpublished'); ?></div> <?php endif; ?> <?php if ($submitted or $terms): ?> <div class="meta"> <?php if ($submitted): ?> <div class="submitted"> <?php print $submitted; ?> </div> <?php endif; ?> <?php if ($terms): ?> <div class="terms terms-inline"><?php print t(' in ') . $terms; ?></div> <?php endif; ?> </div> <?php endif; ?> <div class="content"> <?php print $content; ?> </div> <?php //added by bundes to show the converted audio downloads $convertpath = '/var/www/okno.be/public/sites/default/files/audio_converted/'; $file = $node->audio; $filepath = $file->filepath; $type = explode(".", basename($filepath)); if (file_exists($filepath)) { $output .= l($type['1'], $filepath) . ' : '; } $type = 'mp3'; $filepath = $convertpath . $file->filename . '.' . $type; $downloadpath = 'sites/default/files/audio_converted/' . $file->filename . '.' . $type; if (file_exists($filepath)) { $output .= l($type, $downloadpath) . ' : '; } $type = 'ogg'; $filepath = $convertpath . $file->filename . '.' . $type; $downloadpath = 'sites/default/files/audio_converted/' . $file->filename . '.'. $type; if (file_exists($filepath)) { $output .= l($type, $downloadpath); } $output = theme('fieldset', array('#title' => 'Download:', '#children' => $output)); print $output; //end added by bundes ?> <?php print $links; ?> </div></div> <!-- /node-inner, /node --> _______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
Re: tpl.php file questionAs far as I know drupal only passes the node object to node-tpl.
You will have to process other non-related variables before trying to use them in your tpl file. Furthermore I'm not sure you can use thing like "explode" in a tpl file since it is only intended to provide the presentation of your data and not intended to build it. -----Oorspronkelijk bericht----- Van: themes-bounces@... [mailto:themes-bounces@...] Namens barb Verzonden: woensdag 8 april 2009 21:49 Aan: A list for theme developers Onderwerp: Re: [themes] tpl.php file question cau! thx for the quick reply... > Looking at your source code it appears your template doesn't output any > html. it's handled over the php... - and the 'box' is visible..... (you can check it here at this link: http://okno.be/vodnik-frog ) > Check: your content type is "audio", otherwise node-audio won't work. > You are working in a template-file this has a different lay-out then a > normal php-scriptfile. > Maybe you better post your complete node-audio.tpl.php <?php // $Id: node.tpl.php,v 1.4 2008/09/15 08:11:49 johnalbin Exp $ /** * @file node.tpl.php * * Theme implementation to display a node. * * Available variables: * - $title: the (sanitized) title of the node. * - $content: Node body or teaser depending on $teaser flag. * - $picture: The authors picture of the node output from * theme_user_picture(). * - $date: Formatted creation date (use $created to reformat with * format_date()). * - $links: Themed links like "Read more", "Add new comment", etc. output * from theme_links(). * - $name: Themed username of node author output from theme_user(). * - $node_url: Direct url of the current node. * - $terms: the themed list of taxonomy term links output from theme_links(). * - $submitted: themed submission information output from * theme_node_submitted(). * * Other variables: * - $node: Full node object. Contains data that may not be safe. * - $type: Node type, i.e. story, page, blog, etc. * - $comment_count: Number of comments attached to the node. * - $uid: User ID of the node author. * - $created: Time the node was published formatted in Unix timestamp. * - $zebra: Outputs either "even" or "odd". Useful for zebra striping in * teaser listings. * - $id: Position of the node. Increments each time it's output. * * Node status variables: * - $teaser: Flag for the teaser state. * - $page: Flag for the full page state. * - $promote: Flag for front page promotion state. * - $sticky: Flags for sticky post setting. * - $status: Flag for published status. * - $comment: State of comment settings for the node. * - $readmore: Flags true if the teaser content of the node cannot hold the * main body content. * - $is_front: Flags true when presented in the front page. * - $logged_in: Flags true when the current user is a logged-in member. * - $is_admin: Flags true when the current user is an administrator. * * @see template_preprocess() * @see template_preprocess_node() */ ?> <div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>"><div class="node-inner"> <?php print $picture; ?> <?php if (!$page): ?> <h2 class="title"> <a href="<?php print $node_url; ?>" title="<?php print $title ?>"><?php print $title; ?></a> </h2> <?php endif; ?> <?php if ($unpublished): ?> <div class="unpublished"><?php print t('Unpublished'); ?></div> <?php endif; ?> <?php if ($submitted or $terms): ?> <div class="meta"> <?php if ($submitted): ?> <div class="submitted"> <?php print $submitted; ?> </div> <?php endif; ?> <?php if ($terms): ?> <div class="terms terms-inline"><?php print t(' in ') . $terms; ?></div> <?php endif; ?> </div> <?php endif; ?> <div class="content"> <?php print $content; ?> </div> <?php //added by bundes to show the converted audio downloads $convertpath = '/var/www/okno.be/public/sites/default/files/audio_converted/'; $file = $node->audio; $filepath = $file->filepath; $type = explode(".", basename($filepath)); if (file_exists($filepath)) { $output .= l($type['1'], $filepath) . ' : '; } $type = 'mp3'; $filepath = $convertpath . $file->filename . '.' . $type; $downloadpath = 'sites/default/files/audio_converted/' . $file->filename . '.' . $type; if (file_exists($filepath)) { $output .= l($type, $downloadpath) . ' : '; } $type = 'ogg'; $filepath = $convertpath . $file->filename . '.' . $type; $downloadpath = 'sites/default/files/audio_converted/' . $file->filename . '.'. $type; if (file_exists($filepath)) { $output .= l($type, $downloadpath); } $output = theme('fieldset', array('#title' => 'Download:', '#children' => $output)); print $output; //end added by bundes ?> <?php print $links; ?> </div></div> <!-- /node-inner, /node --> _______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes _______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
|
|
|
Re: tpl.php file questionOK, thanks Van: themes-bounces@...
[mailto:themes-bounces@...] Namens Chris
Sternal-Johnson PHP functions like
explode() can be used in .tpl.php files without issues. On Wed, Apr 8, 2009 at 4:11 PM, Joop Sint Jago <j.sintjago@...> wrote: As far as I know drupal only passes the node object to node-tpl.
Verzonden: woensdag 8 april 2009 21:49
_______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
Re: tpl.php file question> As far as I know drupal only passes the node object to node-tpl. > You will have to process other non-related variables before trying to use > them in your tpl file. mhm - i thought so already, but wasnt't sure. so if i see this right, i have to preprocess the variables in the template.php in order to make new variables available for the node script? i am doing this for the first time and have hardly any experience in php - so i am really puzzled about making new variables available thru template.php. any help would be appreciated or a link to a good manual? (or do i have to learn php from scratch ;) i've checked out quite some manuals but i don't really understand the processing.... thx b# _______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
Re: tpl.php file questionIn Pro Drupal Development this process is explained in detail. Maybe it is
hard to grasp because you have to understand the Theme Registry. A sidestep: Assuming node-audio is a CCk-node, did you consider using CCk-computed field.? -----Oorspronkelijk bericht----- Van: themes-bounces@... [mailto:themes-bounces@...] Namens barb Verzonden: donderdag 9 april 2009 17:31 Aan: A list for theme developers Onderwerp: Re: [themes] tpl.php file question > As far as I know drupal only passes the node object to node-tpl. > You will have to process other non-related variables before trying to use > them in your tpl file. mhm - i thought so already, but wasnt't sure. so if i see this right, i have to preprocess the variables in the template.php in order to make new variables available for the node script? i am doing this for the first time and have hardly any experience in php - so i am really puzzled about making new variables available thru template.php. any help would be appreciated or a link to a good manual? (or do i have to learn php from scratch ;) i've checked out quite some manuals but i don't really understand the processing.... thx b# _______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes _______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
targeting variables in my node-blog.tpl.php fileHello,
I can't seem to figure out how to effectively target two different
values in my node-blog.tpl.php file: $submitted $links For the $submitted value, I'd like to insert some xhtml tags in
there so that I can target them with CSS. Currently it writes the data to the page like this: --- Submitted by super_user on April 9, 2009 - 2:49pm --- But I'd like to get some xhtml tags around the User and the
Month. It would also be nice if I could delete the hour - but that’s
not as important. For the $links value, I'd like to figure out how to remove
the Author. Currently, the $links value writes:"Author's
Blog", "Read More...", and "Add
comments" to the teaser. How do I remove just the "Authors
blog" info from the $links value? Unfortunately, I know enough PHP to get myself confused a lot, and
I've been googling and searching Drupal.org all day with no luck. Hopefully the nice folks on this list can help!! brendan, fresh-off.com Creative Direction & Consultation: Web | Print | Brand http://fresh-off.com 206.328.1067 seattle.usa _______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
Re: targeting variables in my node-blog.tpl.php fileYou have to override the theme function
in your template.php file. I think you can not target it directly in
node-blog.tpl.php Copy the original function to your theme
and rename it: themename_node_submitted() and make the
changes you want. If you install dev module you can see on
your page which theme_functions are responsible for the theming of the
particular items such as $links etc. Van: themes-bounces@...
[mailto:themes-bounces@...] Namens brendan,
fresh-off.com Hello, I can't seem to figure
out how to effectively target two different values in my node-blog.tpl.php
file: $submitted $links For the $submitted
value, I'd like to insert some xhtml tags in there so that I can target them
with CSS. Currently it writes
the data to the page like this: --- Submitted
by super_user on April 9, 2009 - 2:49pm --- But I'd like to get
some xhtml tags around the User
and the Month. It would also
be nice if I could delete the hour - but that’s not as important. For the $links value, I'd like to figure out how to
remove the Author.
Currently, the $links value writes:"Author's Blog", "Read More...",
and "Add
comments" to the teaser.
How do I remove just the "Authors blog" info from the $links
value? Unfortunately, I know
enough PHP to get myself confused a lot, and I've been googling and searching
Drupal.org all day with no luck. Hopefully the nice
folks on this list can help!! brendan,
fresh-off.com Creative Direction
& Consultation: Web | Print | Brand http://fresh-off.com 206.328.1067 seattle.usa _______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
Re: targeting variables in my node-blog.tpl.php filebrendan, You can use template preprocessor. See my latest reply on "Re: how to stop a 'view' from showing a field?" Cheers, CK Ng forDrupal Premium Themes (http://fordrupal.com) - we make drupal beautiful On Fri, Apr 10, 2009 at 3:53 PM, brendan, fresh-off.com <hello@...> wrote:
_______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
Re: targeting variables in my node-blog.tpl.php fileThanks for your responses CK Ng and J. Sint Jago! I don’t think my PHP skills are good enough to write the
necessary function from scratch. However, I'm usually able to modify existing
examples. CK, Based on your response to Sebastian and the reading on
Drupal.org, it seems I need to add phptemplate_preprocess_node() to
template.php. But I'm not sure exactly how its supposed to be
written. Using the Devel Mod I got the following info (or see attached screenshot):
--- parents: node.tlp.php < page.tlp.php function called: theme_links() Candidates Function names: myTheme_links <
phptemplate_links < theme_links Next it lists 2 arrays for the theme_links() function.
Those elements are: links array & attributes array The links array has 3 elements, the first of which is the array I
don’t want to display: blog_usernames_blog ---- I think that’s all of the information I need, but I'm
still not sure what to do next, or where to find an example of the code to
modify and insert into template.php to keep it from showing blog_usernames_blog. I'm stuck, any further suggestions? From:
themes-bounces@... [mailto:themes-bounces@...] On Behalf Of Ng
Chin Kiong brendan, You can use template preprocessor. See my latest reply on
"Re: how to stop a 'view' from showing a field?"
On Fri, Apr 10, 2009 at 3:53 PM, brendan, fresh-off.com <hello@...> wrote: Hello, I can't seem to figure out how to effectively
target two different values in my node-blog.tpl.php file: $submitted $links For the $submitted value, I'd like to insert some
xhtml tags in there so that I can target them with CSS. Currently it writes the data to the page like
this: --- Submitted by
super_user on April 9, 2009 - 2:49pm --- But I'd like to get some xhtml tags around the User
and the Month. It would also be nice if I could delete the hour -
but that’s not as important. For the $links value, I'd like to figure
out how to remove the Author. Currently, the $links value writes:"Author's Blog",
"Read More...", and "Add comments" to the teaser. How do I remove just the
"Authors blog" info from the $links value? Unfortunately, I know enough PHP to get myself
confused a lot, and I've been googling and searching Drupal.org all day with no
luck. Hopefully the nice folks on this list can help!! brendan, fresh-off.com Creative Direction & Consultation: Web | Print
| Brand 206.328.1067 seattle.usa
_______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
Re: targeting variables in my node-blog.tpl.php fileHere's as far as I was able to get using CK Ng's suggestion: function phptemplate_preprocess_node(&$vars, $hook) { //try to remove 'blog_usernames_blog' from links array $vars['links'] = unset($links[0]); } it throws this error on the template.php page: Parse error: syntax error, unexpected T_UNSET As I said, writing php from scratch is difficult for me. Am I even
on the right track? Thanks for any help! Brendan From:
themes-bounces@... [mailto:themes-bounces@...] On Behalf Of brendan,
fresh-off.com Thanks for your responses CK Ng and J. Sint Jago! I don’t think my PHP skills are good enough to write the
necessary function from scratch. However, I'm usually able to modify existing
examples. CK, Based on your response to Sebastian and the reading on
Drupal.org, it seems I need to add phptemplate_preprocess_node() to
template.php. But I'm not sure exactly how its supposed to be
written. Using the Devel Mod I got the following info (or see attached
screenshot): --- parents: node.tlp.php < page.tlp.php function called: theme_links() Candidates Function names: myTheme_links <
phptemplate_links < theme_links Next it lists 2 arrays for the theme_links() function.
Those elements are: links array & attributes array The links array has 3 elements, the first of which is the array
I don’t want to display: blog_usernames_blog ---- I think that’s all of the information I need, but I'm still not
sure what to do next, or where to find an example of the code to modify and
insert into template.php to keep it from showing blog_usernames_blog. I'm stuck, any further suggestions? From:
themes-bounces@... [mailto:themes-bounces@...] On Behalf Of Ng
Chin Kiong brendan, You can use template preprocessor. See my latest reply on
"Re: how to stop a 'view' from showing a field?"
On Fri, Apr 10, 2009 at 3:53 PM, brendan, fresh-off.com <hello@...> wrote: Hello, I can't seem to figure out how to effectively
target two different values in my node-blog.tpl.php file: $submitted $links For the $submitted value, I'd like to insert some
xhtml tags in there so that I can target them with CSS. Currently it writes the data to the page like
this: --- Submitted by
super_user on April 9, 2009 - 2:49pm --- But I'd like to get some xhtml tags around the User
and the Month. It would also be nice if I could delete the hour -
but that’s not as important. For the $links value, I'd like to figure
out how to remove the Author. Currently, the $links value writes:"Author's Blog",
"Read More...", and "Add comments" to the teaser. How do I remove just the
"Authors blog" info from the $links value? Unfortunately, I know enough PHP to get myself
confused a lot, and I've been googling and searching Drupal.org all day with no
luck. Hopefully the nice folks on this list can help!! brendan, fresh-off.com Creative Direction & Consultation: Web | Print
| Brand 206.328.1067 seattle.usa
_______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
Re: targeting variables in my node-blog.tpl.php fileIf you want to remove blog_usernames_blog from $link, put this in template.php /* duplicate theme_links() and add the 3rd line (marked with HERE) */ function phptemplate_links($links, $attributes = array('class' => 'links')) {
$output = ''; // HERE: just add this line, the rest are from theme_links() unset($links['blog_usernames_blog']); if (count($links) > 0) {
$output = '<ul'. drupal_attributes($attributes) .'>'; $num_links = count($links); $i = 1; foreach ($links as $key => $link) {
$class = $key; // Add first, last and active classes to the list of links to help out themers. if ($i == 1) { $class .= ' first';
} if ($i == $num_links) { $class .= ' last'; } if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
$class .= ' active'; } $output .= '<li'. drupal_attributes(array('class' => $class)) .'>'; if (isset($link['href'])) {
// Pass in $link as $options, they share the same keys. $output .= l($link['title'], $link['href'], $link); } else if (!empty($link['title'])) {
// Some links are actually not links, but we wrap these in <span> for adding title and class attributes if (empty($link['html'])) { $link['title'] = check_plain($link['title']);
} $span_attributes = ''; if (isset($link['attributes'])) { $span_attributes = drupal_attributes($link['attributes']);
} $output .= /*'<span'. $span_attributes .'>'.*/ $link['title'] /*.'</span>'*/; } $i++; $output .= "</li>\n";
} $output .= '</ul>'; } return $output; } For changing $submitted, add to your template.php
function phptemplate_node_submitted($node) { // make your changes return t('By !username (posted on @datetime)'), array( '!username' => theme('username', $node),
'@datetime' => format_date($node->created), )); } For phptemplate_preprocess_node, if you want to introduce new variables or modify existing one. Of course it can be used to change submitted as well, but not $links as it has been generated.
function phptemplate_preprocess_node(&$vars, $hook) { $author = theme('username', $vars['node']); $date = format_date($vars['node']->created, 'medium');
$vars['submitted'] = $author . ' - ' . $date; } CK Ng forDrupal Premium Themes (http://fordrupal.com) - we make drupal beautiful On Tue, Apr 14, 2009 at 1:50 PM, brendan, fresh-off.com <hello@...> wrote:
_______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
Re: targeting variables in my node-blog.tpl.php fileWOW!!! THANKS EVERY SO MUCH!!! I would have never gotten that
far on my own! I really, really, really appreciate that CK Ng!!!! Brendan From:
themes-bounces@... [mailto:themes-bounces@...] On Behalf Of Ng
Chin Kiong If you want to remove blog_usernames_blog from $link,
put this in template.php /* duplicate theme_links() and add the 3rd line (marked with
HERE) */ function phptemplate_links($links, $attributes =
array('class' => 'links')) { $output = ''; // HERE: just add this line, the rest are
from theme_links() unset($links['blog_usernames_blog']); if (count($links) > 0) { $output = '<ul'.
drupal_attributes($attributes) .'>'; $num_links = count($links); $i = 1; foreach ($links as $key => $link) { $class = $key; // Add first, last and active
classes to the list of links to help out themers. if ($i == 1) { $class .= ' first'; } if ($i == $num_links) { $class .= ' last'; } if (isset($link['href'])
&& ($link['href'] == $_GET['q'] || ($link['href'] == '<front>'
&& drupal_is_front_page()))) { $class .= ' active'; } $output .= '<li'.
drupal_attributes(array('class' => $class)) .'>'; if (isset($link['href'])) { // Pass in $link as
$options, they share the same keys. $output .=
l($link['title'], $link['href'], $link); } else if (!empty($link['title'])) { // Some links are actually
not links, but we wrap these in <span> for adding title and class
attributes if (empty($link['html'])) { $link['title'] =
check_plain($link['title']); } $span_attributes = ''; if
(isset($link['attributes'])) { $span_attributes =
drupal_attributes($link['attributes']); } $output .= /*'<span'.
$span_attributes .'>'.*/ $link['title'] /*.'</span>'*/; } $i++; $output .=
"</li>\n"; } $output .= '</ul>'; } return $output; } For changing $submitted, add to your template.php function phptemplate_node_submitted($node) { // make your changes return t('By !username (posted on @datetime)'), array( '!username' =>
theme('username', $node), '@datetime' => format_date($node->created), )); } For phptemplate_preprocess_node, if you want to
introduce new variables or modify existing one. Of course it can be used to
change submitted as well, but not $links as it has been generated. function phptemplate_preprocess_node(&$vars, $hook) { $author = theme('username', $vars['node']); $date = format_date($vars['node']->created,
'medium'); $vars['submitted'] = $author . ' - ' . $date; } Cheers, On Tue, Apr 14, 2009 at 1:50 PM, brendan, fresh-off.com <hello@...> wrote: Here's as far as I was able to
get using CK Ng's suggestion: function
phptemplate_preprocess_node(&$vars, $hook) {
//try to remove 'blog_usernames_blog' from links array
$vars['links'] = unset($links[0]); } it throws this error on the
template.php page: Parse error: syntax error,
unexpected T_UNSET As I said, writing php from
scratch is difficult for me. Am I even on the right track? Thanks for any help! Brendan From: themes-bounces@...
[mailto:themes-bounces@...]
On Behalf Of brendan, fresh-off.com
Thanks for your responses CK
Ng and J. Sint Jago! I don’t think my PHP skills are
good enough to write the necessary function from scratch. However, I'm usually
able to modify existing examples. CK, Based on your response to
Sebastian and the reading on Drupal.org, it seems I need to add
phptemplate_preprocess_node() to template.php. But I'm not sure
exactly how its supposed to be written. Using the Devel Mod I got the
following info (or see attached screenshot): --- parents: node.tlp.php <
page.tlp.php function called:
theme_links() Candidates Function names:
myTheme_links < phptemplate_links < theme_links Next it lists 2 arrays for the
theme_links() function. Those elements are: links array &
attributes array The links array has 3 elements,
the first of which is the array I don’t want to display:
blog_usernames_blog ---- I think that’s all of the
information I need, but I'm still not sure what to do next, or where to find an
example of the code to modify and insert into template.php to keep it from
showing blog_usernames_blog. I'm stuck, any further
suggestions? From: themes-bounces@...
[mailto:themes-bounces@...]
On Behalf Of Ng Chin Kiong brendan, You can use template preprocessor. See my latest reply on "Re: how to
stop a 'view' from showing a field?"
On Fri, Apr 10, 2009 at 3:53 PM, brendan, fresh-off.com <hello@...> wrote: Hello, I can't seem to figure out how to effectively
target two different values in my node-blog.tpl.php file: $submitted $links For the $submitted value, I'd like to insert some
xhtml tags in there so that I can target them with CSS. Currently it writes the data to the page like
this: --- Submitted by
super_user on April 9, 2009 - 2:49pm --- But I'd like to get some xhtml tags around the User
and the Month. It would also be nice if I could delete the hour -
but that’s not as important. For the $links value, I'd like to figure
out how to remove the Author. Currently, the $links value writes:"Author's Blog",
"Read More...", and "Add comments" to the teaser. How do I remove just the
"Authors blog" info from the $links value? Unfortunately, I know enough PHP to get myself
confused a lot, and I've been googling and searching Drupal.org all day with no
luck. Hopefully the nice folks on this list can help!! brendan, fresh-off.com Creative Direction & Consultation: Web | Print
| Brand 206.328.1067 seattle.usa
_______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
Re: tpl.php file question - solved!!!ahojte!
> In Pro Drupal Development this process is explained in detail. Maybe it is > hard to grasp because you have to understand the Theme Registry. > > A sidestep: Assuming node-audio is a CCk-node, did you consider using > CCk-computed field.? sintjago! thx so much for your help! i looked at cck-computed field but was rather hesitant to use it. so in the end after asking around and trying to define the variables in template.php (and starting finally to learn php basics myself) i got the solution. it was really simple actually. to find out, how the node.tpl.php is actually build up, this was included in the code of node-audio.tpl.php: global $user; if ($user->uid == '1') { print "<pre>"; print_r($node); print "</pre>"; } so - there the nice code lay, and then it got clear, that the solution was, to include into the $file - this here: $file = $node->audio['file']; so template.php was left out. maybe not an 'aesthetic' solution but rather dirty, but it's doing the job for me. so this is the whole code, and this the output: http://okno.be/vodnik-vitaminC2 <?php //added by bundes - show the converted audio downloads $convertpath = '/var/www/okno.be/public/sites/default/files/audio_converted/'; $file = $node->audio['file']; $filepath = $file->filepath; $type = explode(".", basename($filepath)); // print_r($filepath); if (file_exists($filepath)) { $output .= l($type['1'], $filepath) . ' : '; } $type = 'mp3'; $filepath = $convertpath . $file->filename . '.' . $type; $downloadpath = 'sites/default/files/audio_converted/' . $file->filename . '.' . $type; if (file_exists($filepath)) { $output .= l($type, $downloadpath) . ' : '; } $type = 'ogg'; $filepath = $convertpath . $file->filename . '.' . $type; $downloadpath = 'sites/default/files/audio_converted/' . $file->filename . '.'. $type; if (file_exists($filepath)) { $output .= l($type, $downloadpath); } $output = theme('fieldset', array('#title' => 'Download:', '#children' => $output)); print $output; //end added by bundes ?> _______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
| Free embeddable forum powered by Nabble | Forum Help |