Drupal 6 views_embed_view ignores content filtering? - drupal

may be someone encountered a similar issue. I output a view on the front page of my D6 site using this code:
<?php print views_embed_view("frontpage_news_list", "default" ); ?>
Yet it seems that this way of outputting the view bypasses content filtering for the teaser field (NOT the view filter, but filters applied to the teaser of the node). I see this because I don't output img's in my teasers, and they are not shown when I check preview in the Views UI, yet on the front page the images are shown in this view.
I have another view, with outputs the nodes of the same type in a "Page" output, and the img's are hidden in the teasers there, as required.
Has anyone encountered a similar issue before? I would appreciate any help with this.

<?php
// you can use block_1, ... blocn_n or page_1,...,page_n as display id
print views_embed_view("frontpage_news_list", "block_1" );
// or this way to show view
$view = views_get_viev(YOU_VIEW_MACHINE_NAME);
$view->set_display($display_id);
// $view->set_exposed_input(array('var' => $myvar)); // to set exposed filters
// $view->set_arguments(array(....)); // to set arguments. rtfm ;)
$view->set_items_per_page(0);
$view->execute();
$result = $view->preview();
print $result;
?>

This was a problem with the HTMLawed module, not with the Views. It has been solved by the developer now, so no issue anymore. Thanks for the help, guys!

Related

Wordpress: How to pass additional Content to the blog-preview page?

For each blog-post on my wordpress-blog I'd like to have Teaxtarea where i can pass additional content for that post.
In my case that would be an unordered list which contains a quick overview of the content.
That additional content should be displayed in the preview of the post on the blog-preview-page.
My problem:
I am actually not sure on how to best add this additional content and then pass it to the preview.
Do I use wordpress' custom fields for something like this?
I'm gratefull for a push in the right direction.
Thank you,
Nils
If I understand you right, I'd take a look at "custom meta boxes" functionality - it allows you to add any type of additional input into your blog post admin area, and than display its content on front-end however you like.
There's a nice tutorial series on that topic, with example code snippets:
http://wp.tutsplus.com/series/reusable-custom-meta-boxes/
And if you'd like to display the textarea content only in preview mode, you can use appropriate conditional tag in you template file:
http://codex.wordpress.org/Conditional_Tags#A_Preview
The conditional tag is_preview returns true when a single post is viewed in Draft mode. The following will append post meta to the content when a post is being previewed:
function so16799607_preview( $content )
{
if ( ! is_preview() )
return $content;
return $content . get_post_meta( get_the_ID(), 'my_post_meta', true );
}
add_filter( 'the_content', 'so16799607_preview', 10, 1 );
You should check out Advanced Custom Fields. That's a really stable plugin that lets you create custom meta boxes in posts, pages and custom post types. That plugin does exactly what your question states. Need al little PHP to get stuff from your database, but that is as easy as:
<?php the_field(field_name);?>
And the documentation is pretty good. And if you don't like a plugin, it exports the PHP as well.
Anther tool that does the same is Pods Framework. Both powerfull extensions to any WP install in my opinion.
Hope this helps.

How to hide title from page node Drupal

I'm trying to remove the title of a page node on Drupal. I have this page:
And I want it to look like this:
As you can see, I want the title to be removed, but only for taxonomy terms. If I try to erase it using CSS, I erase al page-titles, so I wanted to use this module, that allows administrators to auto-generate node titles and hide it.
I go to structure -> type content -> my type content, and edit it. I activate the module, and I want to auto-generate titles depending on the node category. I think it should look like this, but it doesn't work...
Any ideas why?
EDIT: Sorry, I forgot to say: yes, when I activate the module, use it, and select the category as the auto-generated title, it works. But it doesn't hide the title...
It also launches this mistake:
Use Exclude Node Title module.
https://drupal.org/project/exclude_node_title
Setting for this module:
Click on Module->Exclude node title->configure
Home » Administration » Configuration » Content authoring
Select All nodes from Basic Page
Check Full Content for hide title from all cms page except home page
Check Teaser for hide title from home page.
If you want to remove the title, you should look into overriding the page and node templates.
page.tpl.php and node.tpl.php
All you need to do is click "View Source" on both of those and copy them to your theme folder. From there you can modify both as required.
From what I can gather, you'll want to remove the print $title from your node.tpl.php.
Have the similar issue before, as far as I remember, I just added some if statement to the code:
<?php if (blah-blah-blah): ?>
<h2> <?php echo $title; ?> </h2>
<?php endif; ?>
Hope, it'll give you a clue.
Some other thoughts: you can make an if statement or rewrite it not only in page.tpl.php but create some specific page-node-type.tpl.php file and overwrite only its $title, or you can try to customize page's output via Views/Panels modules as well.
Also, could you please make more clear, what title do you want to remove? Page title or node title? And it should be removed only when you are looking nodes associated with some taxonomy term (in other words, when you are on /taxonomy/term/n page), am I right?
By using the Context module, you can add classes to the body so you can target just the taxonomy pages in CSS.
Using Context module to set body classes
Sorry guys, it was as easy as hide title tag on "manage presentation"...
You are all right on your responses, but they were not exactly what I needed... thanks!
Use Exclude Node Title module.
https://drupal.org/project/exclude_node_title
another nice solution for specific nodes, is to use the standard $title_prefix/suffix vars, which should be implemented by every theme. using the standard class element-invisible in page preprocess ..
like:
/**
* Implements hook_preprocess_page().
*/
function YOUR_THEME_preprocess_page(&$variables) {
if (isset($variables['node']) && $variables['node']->nid == 1) {
$variables['title_prefix'] = array('#markup' => '<div class="element-invisible">');
$variables['title_suffix'] = array('#markup' => '</div>');
}
}
Every page should contain a heading.
You should always maintain a structured hierarchy of headings within any web page. You should never have a blank heading or even hide it with display:none;. Hiding any content which isn’t viewable by your visitors but is by search engines is against Google’s guidelines as your intention is to only manipulate search engine results by including it. Restyle a H1 so it fits into your design is the best option.
If you still have to hide it then a better option would be to either create a template for that node, content type or page and simply not print the heading.
Or if you want to use CSS then use position:absolute so the heading doesn’t use any space where it is located in the page and text-indent:-9999px; so the text is moved off the screen and no longer visible but at least can be read by screen readers and search engines.
This is how I did it, Switch statement
// Get the name of node
$node_name = node_type_get_name($node);
// Then just add the content types you wish to exclude by overwriting the // $title object with an empty string
switch ($node_name) {
case 'Home page':
$title = '' ;
break;
case 'Event':
$title = '';
break;
case 'Offer':
$title = '';
break;
}

Show Link If Views Basic UI is Editable

I'm using Views Basic UI in Drupal 6 to allow users to edit a views header and title. I would like to cut back on the number of view templates that I have, so that in the future if I need to edit, I would only have to make changes in one place.
To do that, I'd like the views template "views-view--page.tpl.php" to provide a link only if the view is editable as defined by the Views Basic UI: Edit Settings module. I'm just not sure what the code should look like. I think it'd be something along the lines of
<?php if (in_array('views_basic_ui'): ?>
<div class="page-edit"> ...
I don't know what to put in that if statement though, in order to say "only print this button if the view has been selected as editable in the views basic ui settings". I'm guessing somebody that reads/writes code better than me could figure it out pretty quick, but I'd appreciate any help I could get.
Thanks.
ps - it's worth mentioning that the users will not have local tabs, so they won't see the 'view' and 'edit' tabs provided by the module.
Not sure exactly what you need, but the bellow code will check if the user has access to the destination and prints the edit link. But better to go with Views' native edit links. Not sure why you can't use them.
<?php
$path = "admin/build/views/edit/VIEW-MACHINE-NAME";
$item = menu_get_item($path);
if ( $item['access'] ) {
print l(t('Edit'), $path);
}
?>
replace VIEW-MACHINE-NAME with View's machine name.

What is the best way to add a content/view to a node

I am developing a module to display video. I have created a view so-called navigation for the user to select a video from a list.
Now I want o add this navigation to every node with type = 'video'. I don't know whether I should create a template for it ( then I have to put the template file in theme folder which is not so good ) or use some kind of hooks ( I haven't figured out which one to use ) ?
I tried to install http://drupal.org/project/views_attach, however the view only appeared in the content (after Title) which is not what I really want. I want it to be on top of the title.
Please help. I'm using drupal 6
Thanks in advance.
Sounds like you'd just create the navigation block any number of ways, and tell the block to only show on video node types using php in the display rules. Maybe menu_block module can help you here.
You can render the view anywhere you want in your node template with views_embed_view.
Create a template specific for your video node type: node-video.tpl.php and insert the view where you want it.
If you don't want to do it via template files, the Panels module can be used to have different layouts per node type. Once you install it, create a variant under the node_view panel and restric that variant to be selected for nodes of type 'video'
I finally found how to implement a view as block (simply select block as a content view) and I use this code below to display a block in a certain node type
<?php
$match = FALSE;
$types = array('video'=>1);
if ((arg(0) == 'node') && is_numeric(arg(1))) {
$node = node_load(arg(1));
$match = isset($types[$node->type]);
}
return $match
}
?>

Drupal 6: print all body field content to node template file

I tried to display body content with:
<?php print $node->content['body']['#value']; ?>
However, it doesn't display all body content, it just display first paragraph of body content, sometimes 2 paragraph if it is short :/
I need to print all body. how can I do that?
Thanks a lot! Appreciate helps!
The shortened body content hints on it being filled/rendered for 'teaser' view instead of 'full'. In what context do you issue this print statement?
EDIT: The node templates are usually used for both, teaser and full output, but the decision on what to use, as well as the population of the content entries in the node object happen outside of the node template files. Within the node template file, the variable $teaser will be TRUE, if the node is to be shown as a teaser.
So you need to check in what context your node template gets called, as you'll have to configure that context to render the node as 'full'. This could be in many places, depending on who is responsible to provide the nodes you want to theme, e.g. if the node template gets called from a view, you'll need to configure the view to use 'full page' output, if it comes from a module, you'll need to check with the module settings, etc...
In node.tpl.php try
<?php print $content ?>
However,
<?php print $node->content['body']['#value']; ?>
works for me as well.
To get control over your teaser length the master value is set with Post Settings.
(Length of trimmed posts)
To control this by node type try: http://drupal.org/project/teaserbytype
NOTE: Teasers are cached so you'll need to http://drupal.org/project/retease
However, if you want to just get it done in the node template you could run a node_load() and have everything... but that's not the best practice.
FYI: you can control what CCK fields show up in $content under Display Options.
PS: In teaser mode I often make use of truncate_utf8().

Resources