Hi,
I would like to use a view in a multi domain environment, where the filter of the view is dependend on the $base_url of the site.
If $base_url is the default site, the filter should filter specific ad's (related to a specifiv vocabulary and taxonomy term).
If $base_url is a subsite, the filter should only show the ad's in the specific vocabulary and taxonomy term.
I installed the advertisement.module and filled the ad_group vocabulary with:
- default-site
- sub-site
And would like to use the argument handling code with an if statement to display the right view.
Something like: argument handling code:
<?php
If $base_url = ''www.test.com'' then arg(1) = "default-site"
If $base_url = '''www.testsub.com" then arg(1) = "subsite"
Filter on arg(1)..
.......
I am not a coder, so above is more pseudocode
Can somebody help with this?
greetings,
Martijn
Comments
Comment #1
michelleA few of us on IRC worked together and came up with this to try. If it doesn't work, let us know and we'll try to tweak it. Don't forget that you don't want to put the opening and closing php tags around it. That's just so it formats right in the post.
Michelle
Comment #2
summit commentedHi,
Great you replied so fast!
What I would like to achieve to have a specific views-filter based on the $base_url.
I think you have then put the whole filter-code in the argument-handling-code-text-block right?
I tried:
and then copy-paste of the $views->filter peace from the views-export:
But then I got all kind of user-warnings about the sql:
Please help!
greetings,
Martijn
Comment #3
michelleThat's not going to work at all. The argument handling code just sets the arguments. I assumed from your first post that you had an argument that made use of the URL and the code I gave you would set the value of that argument to the URL. You don't go pasting bits of a views export into argument handling code. That will just make a mess.
I don't know of any way to set filters dynamically like that; just arguments. Maybe someone else can answer that part.
Michelle
Comment #4
summit commentedHi,
Michelle thanks a lot for your effort!
On this post I saw a sort of pseudocode which can be of help: http://drupal.org/node/161795#comment-296376
Can may be somebody use this example to help me form my filter-argument-handling-code?
Thanks in advance,
greetings,
Martijn
Comment #5
summit commentedHi,
Until now no luckl.
May be somebody can help related to this: http://drupal.org/node/164471
Can somebody help to make my code above to be able to use filters related to the multisite-site I am on?
thanks in advance!
greetings,
Martijn
Comment #6
Piyavkin commentedThat's right (if there is a page view). Let's just modify it a little:
Code is not tested. Try that.
Beforehand you must to create manually a filter. Something like that:
Field=Taxonomy: Term
Operator=Is One Of
Value= // the value will be replaced in Argument Code section
Option=3 // taxonomy depth
To create dynamically whole filter is unnecessary I think (Drupal not so fast already, you know).
And as Michelle said: "Don't forget that you don't want to put [into field Argument Code] the opening and closing php tags around it. That's just so it formats right in the post".
Comment #7
summit commentedHi,
This is a piece of the argument handling code what is working for me:
I need to alter filter values because I use different subsites in which the tagged terms should not be shown.
What I would like to ask. Is this performance-wise a good solution?
For the rest, thanks for helping me with this!
greetings,
Martijn
Comment #8
sunSorry, unfortunately this support request is way too specific. Please have a look at the issue queue - Views maintainers are buried already. You might want to try to get further support at http://drupal.org/support. Additionally, the answer to your question might be covered in the handbooks at http://drupal.org/handbook/modules/views already.
If you were able to solve this issue on your own in the meantime, you might want to add the involved steps to this closed issue, so other users searching for a similar solution might find it.