Domanda

I have a view which shows particular content type(advertisement). My content type has a field "show only on page" which is a text type. Here I will give the page where that particular content should be shown.

I have created a block which is shown on /blog which is showing all content of advertisement. But I want the ads to show only in the block if the url matches.

For eg. If an adv is added say "abc" with "show only on page" as "/blog/europe/*" then in the block "abc" should be shown only when person visits a url say /blog/europe/france etc.

Now I have created a view but I don't know how to pass the "show only on page" field as an argument in the view.

Basically I would like something like below to happen:

if "page url" contains "show only on field" then select the content
else don't select.

Is this type of filter possible in drupal views? I am hoping views argument may save my day.

È stato utile?

Soluzione

There are different ways of passing arguments to a view, depending on how you are displaying the view. I hope i understand your question correctly. Sounds like you are wanting to filter the contents of your view by the value of "show only on page" field. The actual value of "show only on page" to filter by is passed via the URL.

To do this you must add a contextual filter to your view. Then you would add the value of "show only on page" as a parameter in the URL to that view. In this case, when you load the view it will only display those nodes in which "show only on page" field is equal to the value you passed in the URL.

For example the path to you page view might be "path/to/view". You would then add the "show only on page" argument to this url (e.g. "path/to/view/value_of_show_only_on_page"). When you use this URL your view will be filtered so only content where the value of "show only on page" is equal to "value_of_show_only_on_page" is displayed.

Note in Drupal 6 "contextual filters" are referred to as "arguments" in the Views UI.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top