By stormer on
Hi,
I've got a view which filters the content by node type, and have exposed the filter so that the user is able to select the node types they want to view. However, there are certain node types I do not want to include in the list so I'm wondering if there's some way of selecting which node types to display to the user? Currently, in the node type filter I have selected a number of types I want to display and have set the operator to "is one of", but this has no effect on what is displayed in the exposed filter (which simply displays all node types).
Many thanks for any feedback.
Comments
...
see Removing options from your exposed filters.
BRILLIANT!!!
Thanks so much for that. However, I am stumped as to what to do with this snippet from the solution:
Where do I enter this text in order to get the filter ID?
Thanks again.
...
I've just expanded the comments on that page. I hope they're clearer.
Ok, so I've got the
Ok, so I've got the following code in my template.php
The filter I wish to affect is the third in the list ie. filter ID 1. The view name is newfront. However, once I've done this and go to acces my site I get the following error message: Parse error: syntax error, unexpected '<' in /nfs/c02/h02/mnt/26164/domains/dev.xscriptorium.com/html/themes/garland/template.php on line 56
I can't figure out what I'm doing wrong.
...
You're not supposed to include the
<?php ... ?>tags. These tags are used here on drupal.org's website to get syntax highlighting, and are usually not meant to be copied (I fixed that page to warn against this).thanks for bearing with
thanks for bearing with me.
Anyhow, I've removed the tags at the start and at the end of your code and whilst I'm not getting an error message, it's still not working - my exposed filter still includes the "biography" and "page" node types.
...
Add the following line to the start of your function. It will tell you that the function indeed gets called:
Add the following line right after the "$form =" line to verify that 'filter2' indeed stands for the select-box:
Well, that's certainly
Well, that's certainly working - the two messages are showing up just fine. So what could be going wrong? Incidentally, I'm testing this on two versions of the same site, one web-based and the other running locally on my laptop, with the same results.
...
Can I see the second message? Use http://pastebin.com.
Sorry, when I said both
Sorry, when I said both messages I meant both lines (see here: http://dev.xscriptorium.com/)
...
Does the form I see on that page, 'Select Type', have anything to do with our discussion? Because if it is, the selectbox is the first field on that form --not the third-- so it's 'filter0', not 'filter2'.
No, this message isn't fine. No details about the seletbox are printed, so the selectbox probably isn't the third field on the form.
SUCCESS
Hi,
that was it!!!!!!!!! Well, part of it. So the problem was that I thought the filter I was after was the filter in the View (as opposed to the exposed filter). So I changed that but again, it wasn't working. Then I realised that perhaps the node type needed to be listed by its cck type as opposed to name - as such "biography" was actually "bio"... and that did it.
The message "the selectbox:" is still not showing anything but I guess we're no longer concerned with that. So ,success!!!
Thanks so very much for walking me through this, I really appreciate it.
Problem
Hi!
I have inserted the following code [with some modifications for my site] into the template.php in my danland folder.
It seems that the function is not called because when I use drupal_set_message nothing appears.
How can I solve this problem? Thanks.
Hi Mooffie, got another
Hi Mooffie,
got another question in relation to this one - how would I add other views to the list or would I simply duplicate all the text for each view I want affected?
Thanks very much,
Ole
...
I'm nost sure I understand the question.
If I'm guessing correctly, you want to display several different views on a page, all affected by a single 'node type' exposed filter. Is this correct?
Hi Mooffie, sorry for the
Hi Mooffie,
sorry for the late reply.
If you have a look at http://dev.xscriptorium.com and click on the exposed 'Select Type' button, you'll notice that it only shows 4 items. Now, if you go to http://dev.xscriptorium.com/topranked and click on the button you'll notice that there are a whole bunch of additional content types listed in there. So basically I need to include this view (as well as http://dev.xscriptorium.com/lists) in the template.php so that the buttons show the same list as the first button.
Thanks in advance.
Incidentally, thanks for pointing me in Caroline's direction - she's been helping me out with a couple of projects and is doing a fantastic job.
cheerio
Ole
....
I need a name/password to login, but nevermind, I think you explained the problem well:
If I understand correctly, the current template.php handles only the 'newfront' view (that's ok: it's supposed to). You want it to handle the 'xyz' view as well.
So make a copy of the 'theme_views_display_filters_newfront' function, but rename that copy to 'theme_views_display_filters_xyz'. (Basically, it amounts to what you'd have done if you read this thread anew and applied the instructions to the 'xyz' view instead of to 'newfront'.)
:-)
Brilliant!!!. That worked a
Brilliant!!!. That worked a treat. Thanks very much for your help.
Ole
Views filter ALL option still returns hidden node types
I have the same issue. The code mentioned here works to hide node types from the drop down menu - but if a user chooses the 'ALL' option everything, including the node types that should be hidden - is displayed.
It is possible to remove the ALL option with: unset($form["filter0"]["#options"]["**ALL**"]);
In fact this is what I am doing - although it would be much better to be able to return all of the allowed node types in the view.
If I've understood correctly this is not currently possible with the views module.