I have scoured the forums for what I need, but I've come short. Any help would be greatly appreciated.
I have a view which I would like to embed in a specific content type, "issue." The View simply lists the articles associated with each issue. The problem is that I need to pass two cck field arguments to the view, and I can't figure out what my argument handling code should be. I am using Contemplate to embed the view.
The view itself is a page display, with the url: articlelist. When I run a live preview, it works great. I can pass a volume and a number and it limits the articles correctly.
However, I need this view embedded on an "issue" page, which will have the url: title/@volume/@number
I need to pass volume and number to my view dynamically over the URL.
Here is my code so far, and it embeds the view just fine. How would I set up my argument handler code?
<?php
$view = views_get_view('focus');
print $view->execute_display('page_1', $args);
?>
Comments
Given the view expects
Given the view expects volume as the first argument and number as the second this should work
See for http://groups.drupal.org/node/10129 for more on embedding views 2.
that worked admirably, my
that worked admirably, my friend. thanks.
Hi, I'm looking at something
Hi,
I'm looking at something similar, but I'm having some difficulties putting everything together as I'm still learning Drupal. My question is where do you put the snippet PHP below:
Thanks
With views you can make a
With views you can make a page view which has a path so you can just access the view using the path (no need to embed).
Embedding a view like that show above is a somewhat advance technique and where to place it depends on why it is being done.
Embedding a view within a page
Thanks, I know about setting a path for a page view but what I need is a way to embed a view within a page actually. I defined a menu item to invoke my page. The view embedded in the page would take an argument to select the type of node. Based on the type of node selected, the view would display the node contents...
I hope I make myself understood... Thanks for any help you can provide.
Hi,I am trying to do this.
Hi,
I am trying to do this. My view currently works in panels but the alpha version I am using is unstable and I have a Fatal Error when trying to override a node/%. So I figured the next best solution till Panels is beta is released would be to embed the view directly in the node itself. Your snippet looks like just what I need, I have one argument instead of two. And since it is working in panels I know the view is setup OK. This is what I have embedded ...
but it is not displaying anything. I should add that I have only one argument %1 which is working in panels. Any ideas? Thanks! Kevin
Are you placing this in the
Are you placing this in the node body, is the input filter to set to PHP code?
You might want to check out the View Field module.
I created a node template...
I created a node template... node-company.tpl.php and the current url is node/185 ... maybe that is why it is not working? because my argument is set by taxonomy term? I will check out that module thanks. Cheers, Kevin
Ah, I've actually tested View
Ah, I've actually tested View Field before and it isn't what I need. I need one view embedded in the node template that changes depending on the url. to be specific, i have a node for company information and then the view is for news headlines associated with that company. The news headlines are filtered by taxonomy term which is the company name. so in panels the url is company/% ... so if i setup an alias for for node/185 would that work? Thanks. K
ALmost working
I stripped all my aliases out. I renamed some things... so now I have the view with all news headlines showing on the right page ... but i can't get the argument I need. this one is working without the argument
this one with the argument shows nothing
it must be syntax problem in the snippet?
thanks Kevin
this one shows all
this one shows all headlines
and this one shows no headlines
what i need to do is show only the headlines that agree with the keyword in the url.
If the path is node/{nid}
If the path is node/{nid} there is no argument that corresponds to a tid.
You would need something like
Change $term->tid to $term->name if the view expects the name (tid is more efficient)
Hi, I tried this and I am not
Hi,
I tried this and I am not getting any display. Where in there is the argument? my url is company/talentwave and company=node and talentwave=nid but talentwave is also a term. the headlines that need to show up on the note are associated with the term 'talentwave' and not the node 'talenwave'. I would play with the argument within the view itself but this snippet looks like it wants to convert the node to a taxonomy variables so probably wouldn't work.
As an aside, I imagine i could completely override the node with a view display shown by term. But that brings me back full circle, I can't override node/% because panels does not work yet and I haven't been able to find any other way to override the node. I'd prefer to get it working in the node for now and switch to panels later when a stable version comes out. K
I guess one other option i
I guess one other option i have is node reference which i wanted to avoid because the select list of companies to choose for each headline will be daunting after time. Furthermore, I can't find node reference anywhere in the argument or relationship settings for creating the view. This seems like such a basic thing, get some news headlines relevant to the node id to show on the same page. Occams' razor ... I'm certainly complicating things. Once I figure this out I will create a step-by-step tutorial for non programmers to follow. Cheers, K
getting nid from current path
To get the nid from the current page,
use something like:
Hi,I don't think I want node
Hi,
I don't think I want node ID. I think what i am looking for is to grab a tid from the url and show headlines associated with that company in a view on the company's node page. on the content type where the headlines are entered, the company is also entered as a term. so company and headlines should be connected via the common term name (the company name). It does work in Panels so I believe the view is setup correctly. The problem is to the best of my knowledge, passing the argument through the url. As mentioned previously, this does return ALL headlines ...
But I need only headlines that are associated with the company via term. Many thanks!!
Try this <?php$path =
Try this
Here is a sample company page
Here is a sample company page using the code above http://www.techtagz.com/profile/company/buzz-media. Maybe the argument is wrong? I can't wait to solve this a do a tutorial for everybody. Cheers. Kj
here is the term category ...
here is the term category ... these headlines should appear on the respective compant node http://www.techtagz.com/tags/company/buzz-media
Thank you!
Much appreciated!
For the record ... the full
For the record ... the full url is http://www.techtagz.com/profile/company/% The % is the nid and it is also a tid. The tid is what i am trying to catch in the arguments ... so that's either a 3 or 2 if profile is 0 or 1. but profile is just an alias add-on and isn't associated with any node or term so does it still count as an argument? Since the snippet above works for all headlines it must mean there is an error with the argument syntax in the snippet. Or is it an error in the way the argument is setup? Thanks!
Lets start with "
Lets start with " http://www.techtagz.com/profile/company/% The % is the nid and it is also a tid". Without some special handling the '%' is either a tid or a nid, not both.
One thing to note is aliases do not take additional path elements, so you can have an alias for company/xyz and profile/company/xyz but if the alias is 'company', then 'company/xyz' is not a instance of 'company' with 'xyz' as an argument.
So how are you creating you aliases?
Exactly what is the '%' part?
Thank you for the
Thank you for the clarification. My aliases are structured like this ... for nodes its profile/(content type)/nid and for terms its tags/(% vocabulary name)/(%term name) ...
resulting urls look like tags/company/ABC Co and when clicked you see all content that has been tagged ABC Co which includes news which is a content type plus company profile which is a content type. If you click the company content type you will get the profile node at profile/company/ABC Co
So my understanding is that the argument will use the name ABC Co as a filter and because the view is filtered to only show news node content, I would therefore then only see news headlines associated with ABC Co. As I mentioned before I do get ALL headlines or none. I can't seem to get only ABC Co's headlines. I tried tweaking the code a bit with different argument numbers but that's not working. I might have to go in and adjust the view argument itself but since it was working in panels as desired i figured the view argument was OK. I named the panel path company/% and that worked. however, replicating that path with node aliases is not working.
Aside from my current issue, arguments seems to be very powerful and amazing thing. I can't wait till I get them figured out and mastered. I think the possibilities of what you can do with drupal will be endless.
This "... get the profile
This "... get the profile node at profile/company/ABC Co" makes "profile/company/ABC Co" sound like this is an alias for a particular node.
You also talk not only about views but also panels. Exactly what paths are you using, for the node, view(s) and panel(s). What purpose do the view(s) and panel(s) serve and what exactly is not working.
Another approach, whats you goal?
I'm not using panels right
I'm not using panels right now because they are unstable. but this view was working on a panel page. So I reference the panels in only a troubleshooting sense. Because it worked on a panel page, it is therefore conceivable that it would work on a standard node. As far as goal, its very straightforward. I want to show news headlines related to a company on their company profile page. All other news should be filtered out. Ideally, the solution will work with other types of information as the site grows. What would suggest if it doesn't sound like a view with arguments will do the trick?
nevets, would the same code
nevets,
would the same code work as a php argument handler within the views default argument text area? panels seems pretty stable now. i have the page setup at node/% but it is a page of composite content and I'd like some of the block views to take on a term argument rather than a node argument. right now my views work fine in the view preview, but once they are output on the panel they are not working and I suspect that is because they are not seeing the term in the url. thanks, K
For a views 2 default
For a views 2 default argument handler you would want something like
use taxonomy term instead of taxonomy id as argument
the above works if using term id an argument, how about if using the term name instead?
Although, it noted that : If using term name, it is generally more efficient to convert it to a term ID and use Taxonomy: Term ID rather than Taxonomy: Term Name" as an argument.
If using taxonomy term
If using taxonomy term change
return($term->tid);toreturn($term->name);Thanks so much for this. I'm
Thanks so much for this.
I'm using Ubercart and I want to embed a view under the product with a slideshow of other products in this category (taxonomy term).
I have a view called product_node_category_view that is setup with a slide show (views slideshow module)
I copied node.tpl.php and named the copy -> node-product.tpl.php
I added the following lines to the bottom:
This displayed no view at the bottom of my product node
This displayed all products in all categories in a view below the product node.
This now displays only the other products in the same category
The only problem is that if a product is in two categories, it shows the view twice.
Actually someone a little
Actually someone a little farther up in the thread posted this:
the problem with my code above, is that if your node has more than one taxonomy tag, it will display more than one embedded views at the bottom of your node.
With the code in this post, it only displays one view based upon the taxonomy term of the URL being viewed.
Drupal 7
Don't know if this helps but...
I ran across this explanation of an argument that creates a view that shows related content. Seems somewhat similar to what you're looking for... http://www.hankpalan.com/blog/drupal/related-content-views-2-drupal
Does anyone have this working
Does anyone have this working paasing arguments to an embedded view. I am running against the same problems with views 2. The embedding works without arguments but when I try to send some it does not work.
You might post the code you
You might post the code you are using, remember to place in <code> and </code> tags.
Similar issue - passing cck field from page to an embedded view
Hey guys,
Just saw this discussion and am having a very similar issue with the syntax...
I have a page with a cck field field-your-picture that has a filepath string of filepath = "sites/default/files/0/11_3.jpg"
How can I pass this as an argument to my view? (which is assigned to show up every time this content type is loaded).
Thanks!!! I've been banging my head against a wall for hours!!!!
:)
How do you just embed a view
I'm having trouble just embedding a block view in the header of another view. I found an example http://adaptivethemes.com/take-control-of-your-homepage-with-nodequeue-v... but I keep getting a fatal error when I view the page. I'm using the current release of drupal and views. I'm just trying to get Block A to be in the view header of "news view" but just keep getting errors.
Embed a view
I've run into trouble trying to embed a view as a header directly through the views interface, too. While I haven't gotten a fatal error, more often than not the code I've added just doesn't display any results. Fortunately, if you create a new tpl file using the 'Display output' template (under Style settings >> Theme Information) options, you can embed a view using the same code snippets mentioned in this thread. You just have to add them manually to the views tpl file in the view-header div.
Passing arguments from Exposed Filters to another view
Wondering if someone can help. I know Views allows you to create a "More Link" to display further results but unfortunately I can't use this method. Is there a way using arguments instead that I can pass the values from one view that had used exposed filters to another view as arguments?
Any help would be greatly appreciated.
_
I too have struggled with passing arguments to embedded views. I've been wondering a few things about the dynamics of embedding views.
1) If you have a view with an argument set within the views itself when you build it, why would you still have to add the argument as a parameter within the embed code? Why not just display the view and it will already have an argument, and so the output will be filtered through the argument?
2) If the node alias and the term name are the same as in the posters case, would it be possible just to call the term->name from the URL using the node's name? For example, in my case, a user's name is also a taxonomy menu. The vocabulary is set up for tagging so terms are added automatically. So if I set an argument to use term name and just have it take the URL as is without converting would it function correctly since it would be using a node's name but would also be a valid term name? I know this is confusing because I can't explain it right but here is an example.
sitename/user/John-Smith
The node name is John-Smith. John-Smith is a valid tax term. So if I tell it to use the node's name as a tax term it will use John-Smith, which is valid. I know this doesn't work in many cases because node names and tax terms are usually different. Of course, this does not apply to paths. user/John-Smith is NOT the same as tax-vocab/John-Smith pathwise, but only namewise. Hopefully I've explained my questions in a coherent manner and they don't sound like looney ramblings!