Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By oziumjinx on
I'd like to have a drop down box (not really a dropping menu) that pulls terms from a specific vocabulary. This drop down box needs to be displayed on all pages, within one fixed position.
It's essentially going to be right above all the content, in the middle of the page.
Can i accomplish this with FlexiNodes?
Im running Drupal 4.6, modified FriendsElectric theme (PHPTemplate driven).
I'm not that good with PHP code, so any snippets you can recommend are very much appreciated.
Thanks,
-=Vince
Comments
I asked a similar question
I asked a similar question here: http://drupal.org/node/47247
I still haven't figured out how to do it yet. I'll let you know if I find out how to do it.
2 of my Drupal sites:
Small Farm Resource Center
Israel Travel Center
I'm populating a select menu
I'm populating a select menu (aka drop-down, jump menu) on my site by dynamically pulling terms from a particular vocabulary out of the taxonomy tables in the database. In addition I'm using the term description for the displayed select items. Here is the code I used:
I based this code off of something I found on this site, I think in the handbooks, I just can't seem to find it again. There was also a different version with a submit button that didn't use any java script. If I can find it again I'll put up the link here. In the meantime, I hope this helps.
Thanks Colorado!
Thanks Colorado!
This looks like something I'll be able to customize to fit some of my needs. I'll have to play around with it in the next couple days.
I think that's twice now that you've help me with something I needed. Thanks a lot!
2 of my Drupal sites:
Small Farm Resource Center
Israel Travel Center
I'm happy I can help!
I'm happy I can help! If I can at least answer more questions than I ask, then I think I bring value to the community. I encourage everyone to do the same :-)
(Hmm... I think I'll make that my new signature...)
I appreciate your kind words.
Version with submit button
This version might be a bit more useful as the other uses the description rather than the name and this example will take users to the taxonomy term page. It also adds a button for submit since I couldn't get the pure js way working on my site. Change .vid=10 to whatever vocab you want to select from. You can find the number by hovering over the edit vocab link on the admin taxonomy page.
Fatal error when using code in a block
Hi,
I copied your code and changed the vid to reflcect the term I wanted "vid=1", I also changed mysite to the url representing my site. I pasted the new code into a block and got the following error message.
Fatal error: Call to undefined function: form_select() in /home/.laos/sergsoft/sergsoft.com/drupal7/includes/common.inc(1107) : eval()'d code on line 10
Line 10 of my code is:
$category_select = form_select('', 'category', '', $t_description, $description = NULL, 'on Change="top.location.href=document.getElementById(\'edit-category\').options[document.getElementById(\'edit-category\').selectedIndex].value"', $multiple = FALSE, $required = FALSE);
What do I need to change in order to get it to work. By the way, I'm testing this on Drupal 4.7 beta 4.
Any help would be greatly appreciated.
4.7 vs 4.6
4.7 uses the new forms api.
Here is my working dropdown code.
VID = the taxonomy you want to select by.
FORMNAME = the name of the dropdown
-=-=-=-=-=-=-=-=-=-=-=-=-=-=
http://www.shanghaiguide.com
I havea a error
It dont appear, but if i change on the finished..
by
The form appear, but dont work and give a warnning:
* warning: implode(): Bad arguments. in /var/www/vhosts/myhost/httpdocs/includes/form.inc on line 291.
* warning: implode(): Bad arguments. in /var/www/vhosts/myhost/httpdocs/includes/form.inc on line 291.
Taxonomy Jump Menu Snippet
Hello, I don't know if anyone has worked out how to do this.
I have been trying with the code below which works, but at the same time keeps showing the error :-
warning: implode() [function.implode]: Bad arguments. in /var/www/html/craftscouncil/includes/form.inc on line 292.
warning: implode() [function.implode]: Bad arguments. in /var/www/html/craftscouncil/includes/form.inc on line 292.
If anyone has a fully working snippet for Taxonomy Jump Menu, or can tell me where I am going wrong with this I would be very greatful.
the code i'm using is printed below.
Yes, same on me:
"return form_render" shows the dropdown, but also the two warnings above..
When i choose a country from the dropdown i am redirected to
mysite.com/<i>a_path_auto_term_here</i>/taxonomy/term/x.
Unfortunately that path term misleads my link and i get to a "page not found".
Any idea on how to solve this?
still warnings, but path issue solved
using the full URL solves the problem with pathauto. Change:
to
The two Warnings are still there though...
Perhaps..
I hope to try this but I noticed the vid is hardcoded.
You need to set it to your vocabulary's vid or add code get the vid from the name.
nope
sorry lekei, somehow i missed your reply here..
yes, i changed the hardcoded $vid to reflect my category, but the warnings are still there.... :(
Warnings squashed!
we were using the wrong function.
Instead of form_render, drupal_get_form has to be used to kill thoose two Warnings.
Just change the very last line to:
return drupal_get_form('country_dropdown', $form);
and everything will run smooth! :)
4.7.2 common.inc syntax error.
In a block, I get the Parse error: syntax error,
unexpected T_STRING in ../includes/common.inc(1158) : eval()'d code on line 28.
I cannot tell you why. I don't know.
I have this error, do you know why?
Fatal error: Cannot use [] for reading in /nfsn/content/mightyzero/htdocs/includes/common.inc(1158) : eval()'d code on line 4
(drupal 4.7.2)
Apostrophe returns '#039'
drupal 4.7
return -->
also i try
#attributes' => array('onChange' => "top.location.href=document.getElementById(\'$formname\').options[document.getElementById(\'$formname\').selectedIndex].value")
but nothing
How can I have multiple drop
How can I have multiple drop down boxes that build a single link?
Basically:
http://mysite.com/taxonomy/term/1,2
or
http://mysite.com/taxonomy/term/1+2
So the visitor at the site selects a term from the first pull down menu and then selects another term for a differant vocab from a second pull down menu then hits submit to provide links like those above.
Let me know if I need to explain this more.
Michael
2 of my Drupal sites:
Small Farm Resource Center
Israel Travel Center
Not drop downs, but have a look here...
http://drupal.org/node/55192 (the site is also listed in my sig) for an example of generating a 'filter' menu with terms from another vocab.
Late reply but I'm also part way into writing a 4.7 module to do the same thing a bit 'cleaner'. Instead of using a patched version of taxonomy_context it will be a standalone module that uses a block.
Let me know if you want any more info...
--
Anton
New to Drupal? | Forum posting tips | Troubleshooting FAQ
Example Knowledge Base built using Drupal
for specific vocabularies...
how would I assign this drop down box to only pull terms from a specific vocabulary? Im planning on having two of these pull downs within my site, each for a specific vocabulary.
Im not too familiar with PHP or MySQL but if you can point out the locations and which values to alter, I would appreciate it.
Thanks,
-=Vince
Already answered
I put this above, you need to change the value of .vid=10 to be whatever number of your vocab. You find this by goint to the page admin/taxonomy and hovering over "edit vocabulary" and you will see the number in the url for that vocab.
I have a question
I modified this example to try to replicate the way TheOnion has their Archive Pulldown menu.
When I have:
$t_description['http://www.americanpublicradio.com/gov/views/'.$term->description] = $term->description;
set to my specific path it works great in Firefox, but in IE it keeps concatenating the url to the end of whatever page I am on.Any ideas?
Yes I had the very same
Yes I had the very same problem when I just used the specific (relative) path URL. It may not be the best solution, but I use the absolute URL as is used in the code snippet you posted (i.e. http://mydrupalsite.com/views/etc...), NOT just a relative path URL (i.e. views/etc...). As long as you use an absolute URL path there I think it should work fine.
---
"Please drupal responsibly: give as much help as you get."
That was it.
That's odd but it works. Thanks.
Drop Down Box Dynamically Filled With Taxonomy
good example, maybe contribute to documentation.
Apache is bandwidth limited, PHP is CPU limited, and MySQL is memory limited.
Here's that link I was
Here's that link I was looking for, that I used as a starting point for the example code above:
http://drupal.org/node/17762
---
To keep the community strong, please answer as many questions as you ask.
Great start...
Im still new to Drupal and need a bit more direction. Should i be placing this code within my page.tpl.php file in the correct location, or does this need to go into a block I create?
Also, Im wondering if this code can be embedded within
Thanks again for the help.
-=Vince
code placement
You can place the code in a block, in a node or in your template depending where you want it. If you choose a block or node be sure that the php filter is selected. Yes, php lets you put tags within the code. Just use regular div tags and be sure to close them.
Drop Down Box Dynamically Filled With Taxonomy
Great contribs!
what about submitting to PHP snippets ?
Apache is bandwidth limited, PHP is CPU limited, and MySQL is memory limited.
code snippet for select fields within a form
Here is a little code snippet that might be of use to someone:
It allows hierarchies to show in multiple select fields....
Thanks for the snippet, but
Thanks for the snippet, but where does it go, and which drupal version does it work with?
---
"Please drupal responsibly: give as much help as you get."
hope this helps
I have created a special form for inputting businesses. each business is associated with a category which is defined with taxonomy.
here is a snippet of that function.
hope this helps.
example
cool contribution. Do you have an example of this so I could see exactly what it does? Also, I see the word "category" a lot in there. Is this for the standard taxonomy or category module? Finally, does this work only with terms with subterms, or also with vocabs?
Putting it ALL Together for 4.7.x ...
OK, here's a complete, working 4.7.x version of a Taxonomy Select Menu snippet that you can use for a block, on a page, or wherever you can put some PHP on your site. Only 4 or 5 things you need to change in the code below:
1) Where it says $vid=1;, replace the number 1 with the vocabulary ID number for the vocabulary you want to use to populate the drop-down with the terms in that vocabulary.
2) Where it says $formname="Company";, replace the word Company with the word(s) you want your users to see as the default text in the drop-down after List by.
3) Optional: Where it says $options[] = t('List by ' . $formname);, replace List by with the word(s) you want at the beginning of the default text in the drop-down.
4) Where it says $options['http://www.yoursite.com/taxonomy/term/'.$term->tid] = $term->name;, replace yoursite.com with the URL of your drupal website.
5) Where it says return drupal_get_form('Company_dropdown', $form);, replace the word Company with the same word you used in step 2) above - these two text strings must match.
Thanks to everyone who contributed to this thread!
---
"Please drupal responsibly: give as much help as you get."
Is it working on some site.
Is it working on some site. would be interesting to see it working somewhere
Great snippet
except for a couple of things:
1. the dropdown menu lists only the main categories in the vocabulary, but does not list children ones:
example:
Voc:
Countries
Cats:
Argentina
Armenia
Brazil
--Cearà
--Paranà
it lists only 'Argentina, Armenia, Brazil'
2. It odes not respect URL aliases: it always redirects to '/node/n', even if that node is aliased as '/country/brazil'
This apart, all the rest works fine as aspected, thank you!
I hope someone better at PHP
I hope someone better at PHP than I am can add those capabilities. It's probably something simple.
---
"Please drupal responsibly: give as much help as you get."
Is it supposed to work also for Drupal 5?
I'm using Drupal 5.0 RC1 and get the following error message:
where X is the name of the vocabulary.
I'm inserting it using the Front Page module.
No, I have only taken it as
No, I have only taken it as far as 4.7.
HOWEVER, the Views Filter Block module produces similar results and DOES have a version for 5.x in development:
http://drupal.org/project/views_filterblock
---
"Please drupal responsibly: give as much help as you get."
Thank you
Thanks for the advice, I will definitely try it out as soon as I get the Views module to work. But this might require me to change hosts first...
I described the problem here:
http://drupal.org/node/108278)
5.0 version
There seems to be a solution in the snippet section for 5.0:
http://drupal.org/comment/reply/48843/186101
Best regards
Stefan
5.x snippet
I posted this today in the snippet book page http://drupal.org/node/91924#comment-209160
Hope this helps
RGdS, Gustavo
manuj's question
I´ve implemented it creating nodes as explained by colorado in the comment above http://drupal.org/node/48843#comment-167478
The implementation was really easy, no more than an hour. I really want to thanks colorado.
Manuj, if you're still interested, take a look in
http://www.inforo.com.ar/AccesoRapido2
Regards,
Gustavo
So glad it helped
So glad it helped someone!!
---
"Please drupal responsibly: give as much help as you get."
URL alias
Anyone working on the URL alias problem?
Many thnx in advance.
Views Filter Block Now Does This...
There is now a module, Views Filter Block, that accomplishes this for Drupal versions 4.7.x and 5.x:
http://drupal.org/project/views_filterblock
---
"Please drupal responsibly: give as much help as you get."
Quiz module "addqustion" tab filter question list not working
Hi,
I installed quiz module.After that i created one Vocabulary using admin/cateroies addvocabulary with multichoice type after that I created some sub vocabulary under that now when I am going to create quiz and going to addquestion tab I can choose vocabulary which i created but when i press button callled "filter question list" the question are not filter as per vocabulary.
Do you have any solution regarding my query ??