1

I've created a landing page/portal content type and created a series of views for it. However I have run into a problem, i'm not sure how to pass arguments from the urls to the block views on these portal pages.

Basically, if a user goes to http://mysite.com/portal/action I want action which is a taxonomy term to be used as an argument for the block views on the page. Any ideas?

EDIT: To help clarify I am trying to create a page which pulls in information from other parts of my site based on a taxonomy term, so for example http://mysite.com/portal/action would go to a page which contains blocks displaying things like latest news posts in the action catgeory etc.

So far I have created a content type called portal that lets the author set the topic of a portal and then a series of text boxes to add some custom content to the page.

I then set up a view with a series of displays which creates the blocks that pull in information from other parts of the site such as news, and also turned the custom fields made during the creation of the content type as blocks on that page.

My issue is setting up the arguments within this view so that it changes based on the url. So if i created a horror portal page at mysite.com/portal/horror the content would be those items tagged with the horror taxonomy term.

Hope this makes sense?

Edit 2 Solved: Thanks everyone for your help. I ended up adding the following code to the provide default field

    if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
if ($node) {
return $node->title;
}
}

2 Answers 2

3

I hope the said page is a view page in itself and you are passing a argument to that page.

If that is the case then you should check "Provide Default" value when you add the view and then select the required property from the dropdown. You would have something like get term id from url or what ever your argument is. Select that and it showup as you want.

If you need more clarification it would be good if you can export the view you have created or explain how you have created the view.

3
  • @ghost1990 I'm pretty sure there's a 'term by name' validator available as well so it should be reasonably easy if you follow Mohammed's instructions
    – Clive
    Commented Jan 24, 2013 at 15:03
  • I created a content type which takes in some custom information for some other blocks on this page. The view itself is a series of blocks. Have I gone about this the wrong way then?
    – ghost1990
    Commented Jan 24, 2013 at 15:12
  • Could you explain in detail what you have done and what you wanted to achieve Commented Jan 24, 2013 at 15:14
2

Can you not just use views contextual filters for this? Contextual filters allow you to filter content based on parameters in the URL.

Here's an example of how Contextual filters would work:

http://www.metaltoad.com/blog/using-drupal-contextual-filters-views

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.