|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
how to stop a 'view' from showing a field?Hello listers,
Hope this is the right place to ask this question. I am building a theme and I have little icons that I want to have appearing when there is a 'File - CCK' field present. The field is optional in the content-type. I have created a view for the page that shows the content, and when the file-cck field is empty, it still shows all the surrounding <div> and <a href> tags, which triggers my CSS and then I still show the little custom PDF icon; only I want it to be blank. When I click on the View for the field: file-cck (generic files) I only see the options: - Exclude from display - Rewrite output field - Output this field as a link - Trim to max length - Link this to its node - Label [none/drop down] - Format [generic files] I can't see from this list any way to have it be conditional; ie: only display Field formatting [Div+a href] if there is actually any data present. Thanks for your help, hopefully this is an easy one. :) Kind, _______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
Re: how to stop a 'view' from showing a field?If this is for views 2 you can provide a template file that over rides
the theming for that field, click "information" (next to "Theme" in "Basic settings" column) for the file name(s) you can use. _______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
Re: how to stop a 'view' from showing a field?Sebastian,
You'll probably need to do this through views template. Here's the handbook page on this theming: http://drupal.org/node/352970 Basically you'll want to target that field with a template and put in conditional code or otherwise change the tags surrounding the field output. (If you have any questions after reading the handbook page let me know, as I wrote a lot of what is there and I'm looking for ways to improve anything that's unclear.) --ivan -- Rootwork: Powering grassroots networks from the bottom up ivan@... http://www.rootwork.org phone: 202.730.9465 Skype: rootwork Twitter: rootwork On Apr 8, 2009, at 8:56 PM, sebastian wrote: > Hello listers, > > Hope this is the right place to ask this question. > > I am building a theme and I have little icons that I want to have > appearing when there is a 'File - CCK' field present. > > The field is optional in the content-type. I have created a view for > the page that shows the content, and when the file-cck field is > empty, it still shows all the surrounding <div> and <a href> tags, > which triggers my CSS and then I still show the little custom PDF > icon; only I want it to be blank. > > When I click on the View for the field: file-cck (generic files) > > I only see the options: > > - Exclude from display > - Rewrite output field > - Output this field as a link > - Trim to max length > - Link this to its node > - Label [none/drop down] > - Format [generic files] > > I can't see from this list any way to have it be conditional; ie: > only display Field formatting [Div+a href] if there is actually any > data present. > > Thanks for your help, hopefully this is an easy one. > :) > > Kind, > _______________________________________________ > themes mailing list > themes@... > http://lists.drupal.org/mailman/listinfo/themes _______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
Re: how to stop a 'view' from showing a field?Thank you Steve,
I've looked into the theming of the fields, and I have copied a new: "view-view-fields.tpl.php" file to my theme folder. I can get it to react, but I am lacking some basic PHP wisdom. I want to make a conditional statement, so that if the "title" property of the field is empty, don't display anything. My problem is I can't see how to access the title. This is definitely wrong [line 2 is the important one], but here is how I am trying it: <?php if ( $field->class == "field-pdf-fid" ): ?> <?php if ( $field->title != "" ): ?> <<?php print $field->inline_html;?> class="views-field-<?php print $field->class; ?>"> <?php if ($field->label): ?> <label class="views-label-<?php print $field->class; ?>"> <?php print $field->label; ?>: </label> <?php endif; ?> <?php // $field->element_type is either SPAN or DIV depending upon whether or not // the field is a 'block' element type or 'inline' element type. ?> <<?php print $field->element_type; ?> class="field-content"><?php print $field->content; ?></<?php print $field->element_type; ?>> </<?php print $field->inline_html;?>> <?php endif; ?> <?php endif; ?> Thanks a bunch Steve! p.s. I can't see how to combine && and || conditionals or 'else' statements in PHP code written like this without throwing a huge error. I'm used to seeing PHP code written more as a flow without constant <?PHP : ?> breaks... anyways, not critical for now as I can work around it, but it is bugging me. Also, isn't the "->" an assignment operation? It's use here baffles me... Yes: I'm a wee green newbie php person, sigh. Kind, Sebastian. Steve Ringwood wrote: > If this is for views 2 you can provide a template file that over rides > the theming for that field, click "information" (next to "Theme" in > "Basic settings" column) for the file name(s) you can use. > _______________________________________________ > themes mailing list > themes@... > http://lists.drupal.org/mailman/listinfo/themes > _______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
Re: how to stop a 'view' from showing a field?Hi Ivan,
Thanks for the link, I've been trussing about for a few hours, but I can't get anything meaningful to output. I added: <?php print '<pre>' . htmlentities(print_r($rows, 1)) . '</pre>'; ?> To the views-view.tpl.php and got this output: Array ( [0] => template_file [1] => variables [2] => template_files [3] => view [4] => zebra [5] => id [6] => directory [7] => is_admin [8] => is_front [9] => logged_in [10] => db_is_active [11] => user [12] => rows [13] => css_name [14] => name [15] => display_id [16] => empty [17] => exposed [18] => header [19] => footer [20] => more [21] => feed_icon [22] => attachment_before [23] => attachment_after [24] => pager [25] => admin_links_raw [26] => admin_links [27] => dom_id ) Which doesn't really help me [i think], unless I am expected to dig into each level from here?? If I look at the comments in the Views->theme->information->views-view.tpl.php I see no change to the comments written there, though I do see the above Array stuff re-printed to the comments area. If I put the above code instead into: views-view-fields.tpl.php Then I get no output change when I run the page [strage?] and if i look at Views->theme->information->views-view-fields.tpl.php or at views-view.tpl.php I see no change to the comments at the top, nor any output at the bottom [ie no change at all] Am I putting it in the wrong file? If I try add be 'smart' and add: <?php print '<pre>' . htmlentities(print_r($fields, 1)) . '</pre>'; ?> To the bottom of the: views-view-fields.tpl.php file, I break the page... [get a 100% "white" page] Sigh, Still trying to figure out how I can simply identify variables... :P Thanks! Sebastian. Ivan Boothe wrote: > Sebastian, > > You'll probably need to do this through views template. Here's the > handbook page on this theming: > > http://drupal.org/node/352970 > > Basically you'll want to target that field with a template and put in > conditional code or otherwise change the tags surrounding the field output. > > (If you have any questions after reading the handbook page let me know, > as I wrote a lot of what is there and I'm looking for ways to improve > anything that's unclear.) > > --ivan > > > -- > Rootwork: Powering grassroots > networks from the bottom up > > ivan@... > http://www.rootwork.org > phone: 202.730.9465 > > Skype: rootwork > Twitter: rootwork > > > > On Apr 8, 2009, at 8:56 PM, sebastian wrote: > >> Hello listers, >> >> Hope this is the right place to ask this question. >> >> I am building a theme and I have little icons that I want to have >> appearing when there is a 'File - CCK' field present. >> >> The field is optional in the content-type. I have created a view for >> the page that shows the content, and when the file-cck field is empty, >> it still shows all the surrounding <div> and <a href> tags, which >> triggers my CSS and then I still show the little custom PDF icon; only >> I want it to be blank. >> >> When I click on the View for the field: file-cck (generic files) >> >> I only see the options: >> >> - Exclude from display >> - Rewrite output field >> - Output this field as a link >> - Trim to max length >> - Link this to its node >> - Label [none/drop down] >> - Format [generic files] >> >> I can't see from this list any way to have it be conditional; ie: only >> display Field formatting [Div+a href] if there is actually any data >> present. >> >> Thanks for your help, hopefully this is an easy one. >> :) >> >> Kind, >> _______________________________________________ >> themes mailing list >> themes@... >> http://lists.drupal.org/mailman/listinfo/themes > > _______________________________________________ > themes mailing list > themes@... > http://lists.drupal.org/mailman/listinfo/themes > themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
|
|
|
Re: how to stop a 'view' from showing a field?Sigh, I'm a fairly smart person, at least, I thought I was... but the
more I try and figure out things in Drupal, the more lost I become. My site is 90%+ done, but these last ordeals are really painful to unravel... Where is the phptemplate_preprocess_node? I've been looking everywhere to find this, is it a field in the admin tool? or: A *.tpl.php file I am supposed to make from scratch? ie: http://drupal.org/node/223430 If its the later, I have no idea what is going on with all these 10 preprocessors... are there examples of these files? Thanks, Sebastian. Ng Chin Kiong wrote: > sebastian, > > Actually don't need to touch view or view template. The more 'natural' > way is to check it under phptemplate_preprocess_node, if the field's > content does not exist, add an additional CSS class to the node (says > 'no-field-A'). This way you theme the node + the view or other ways that > you retrieve a node. > > In your CSS, just theme > .no-field-A .field-A { > display: none; > } > > > Cheers, > CK Ng > > forDrupal Premium Themes (http://fordrupal.com) > - we make drupal beautiful > > > On Fri, Apr 10, 2009 at 2:19 AM, <themes-request@... > <mailto:themes-request@...>> wrote: > > > > Message: 1 > Date: Wed, 08 Apr 2009 17:56:46 -0700 > From: sebastian <inforazor@... <mailto:inforazor@...>> > Subject: [themes] how to stop a 'view' from showing a field? > To: themes@... <mailto:themes@...> > Message-ID: <49DD47CE.9070008@... > <mailto:49DD47CE.9070008@...>> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > Hello listers, > > Hope this is the right place to ask this question. > > I am building a theme and I have little icons that I want to have > appearing when there is a 'File - CCK' field present. > > The field is optional in the content-type. I have created a view for the > page that shows the content, and when the file-cck field is empty, it > still shows all the surrounding <div> and <a href> tags, which triggers > my CSS and then I still show the little custom PDF icon; only I want it > to be blank. > > When I click on the View for the field: file-cck (generic files) > > I only see the options: > > - Exclude from display > - Rewrite output field > - Output this field as a link > - Trim to max length > - Link this to its node > - Label [none/drop down] > - Format [generic files] > > I can't see from this list any way to have it be conditional; ie: only > display Field formatting [Div+a href] if there is actually any data > present. > > Thanks for your help, hopefully this is an easy one. > :) > > Kind, > > > > ------------------------------------------------------------------------ > > _______________________________________________ > themes mailing list > themes@... > http://lists.drupal.org/mailman/listinfo/themes themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
|
|
Re: how to stop a 'view' from showing a field?Sebastian , You may get better response in support forum. phptemplate_preprocess_node() should go inside your template.php Google and Drupal handbook is your friends =)
/* this goes into template.php */
function phptemplate_preprocess_node(&$vars, $hook) { $node_classes = array(); // may need to check content of $vars['node']->field_MYFIELD?
if ($vars['node']->type == "YOUR_CONTENT_TYPE" && $vars['node']->field_MYFIELD) { $node_classes[] = 'node-no-MYFEILD'; }
$node_classes = array_filter($node_classes); $vars['node_classes'] = implode(' ', $node_classes); } /* this goes in your node.tpl.php */
<div ... class="node <?php print $node_classes; ?> ..."> Cheers, CK Ng forDrupal Premium Themes (http://fordrupal.com) - we make drupal beautiful On Fri, Apr 10, 2009 at 2:53 PM, sebastian <inforazor@...> wrote: Sigh, I'm a fairly smart person, at least, I thought I was... but the more I try and figure out things in Drupal, the more lost I become. My site is 90%+ done, but these last ordeals are really painful to unravel... _______________________________________________ themes mailing list themes@... http://lists.drupal.org/mailman/listinfo/themes |
| Free embeddable forum powered by Nabble | Forum Help |