Dynamic Select in Drupal - drupal

In my way of learning drupal, I got stuck in this issue. I have Taxonomy vocabularies that I set as tree with each node have different depth. Now, I need to display it in select box in a way that only one select(the parent terms) at first. On change, it will fetch term's children and display another select box below it. This goes until the last term doesn't have any children.
How do I do that in drupal?

I'm not sure I understand the question, but I think Hierarchical Select could help if this is a question about the UI

not so clear question, may be using http://api.drupal.org/api/function/taxonomy_get_tree/6 will be helpful.
[edit]
You can use the depth parameter to make sure that you only have the top level items in your first select. Then you can (through an ajax callback) get sub items using the parent parameter.

Related

Multi-Select Suggest Box?

This question is somewhat building off of this one regarding how to add and view Many-to-Many relations.
I have one Model called Contacts with a Many-to-Many relation to itself (Children and Parents).
If I go to a Child Item, I want to be able to have a field called Parents, where I can select the Child's parents. Since the Model will have hundreds of contact items, a Multi-Select widget would not be practical. I need the suggest box functionality to make it easy to find and select the Parents. However, a Suggest Box alone just seems to be able to hold one value, so the question is, how can I use a Suggest Box to set multiple values that are easily added and removed? It would be like having the result of a Suggest Box added to a Multi-Select field.
How might this be possible?
Any assistance is much appreciated. Thank you!

Drupal 7 - show view without a specific node id

I like to set a contextual filter with a NID that shouldn't show up in the result list when entered. However i can't find a way in drupal views. Is contextual filters the right approach?
Use-Case: Within a node, at the end of content there is a view loaded with more related topics to this node (they all share the same category). But, I don't like to see the current node within this view result.
How can I achieve this?
I am glad for every help. Thanks in advance!
Have the same problem years ago, and as far as I remember I've used Relevant Content. But for Drupal 7 there is only a dev version, so here is a comparison list of similar modules.
Also, check out this great answer - https://stackoverflow.com/a/11367731/1003329 I guess it's exactly what you are looking for.

Drupal Search in Block View

i need to create a block View with a search box attach to the header in order to search nodes for one specific content type. I don't know how to achieve this, so i ask for your help. Something like the attached photo.
I'm not exactly sure here, but it sounds to me like you want to:
Create a view;
add a "filter" which limits the view to only your desired content type;
add an "argument," and then expose this argument, for either title, body, or one of your text fields.
Unfortunately:
This alone will not search the whole node. If most of your content is in body, this would probably be a good way to do it. But, for example, if for some reason you have a title like "Bicycles in Timbuktu" with a body that does not contain the word "Timbuktu" - were your users to search for Timbuktu, this item would not appear. That said, it's probably a rather rare case, and if you are simply aiming for happy users, and not rigorous perfection, this will likely be enough.
That said, Kniganapolke's suggestion of checking out Custom Search is excellent. The advice here is more applicable if you want to do this as you've designated and using the power you have with Views (and the other possibilities they offer), rather than a more dedicated-type module. If you don't have other specifications which require you to use Views, I'd guess that Custom Search will likely be the better solution.
Have you tried Custom Search module?
If anybody is interested, i have edited the header block view and load a custom_search_block inside it.
Thanks anyway
create a view with the content you want and then filter it by content. Expose the filter.
http://beeznest.wordpress.com/2011/11/01/create-a-view-to-search-on-content-title-in-7-steps-in-drupal-7/

Display content in two columns with fixed height in drupal

I'm in need of some pointing in the right direction here...
I have a site with a couple of different content types. I want to display this content in a book-like layout. The book should be of a fixed width and height and the pages should be populated with as many nodes as can fit. It should be in two columns, with the left column being filled before the right one.
How should i approach this?
I have been thinking about a few solutions, don't know which are possible and which one is best or which i can combine.
I could just create a view that selects more nodes than is need. Then check how long the nodes is in the theming layer and throw away the nodes that aren't needed. Pagers need to be fixed too.
Use panels in combination with views to display one view in two columns, if this is possible. Need a way to determine the amount of nodes that is displayed on each page, based on content length.
Write a plugin/handler for views so that i can select an amount of nodes that has an maximum, predetermined, max content length.
Write a new display-style for views that shows content in two columns with fixed heights.
Write a custom module, leave views and panels out of it and do everything myself with db_queries.
Would appreciate and guidance a lot. Not looking for a finished solution, i'm not afraid to code and i will contribute back if i create something that someone else can use (like a views plugin). Just need someone to guide me in the right direction :)
The hardest thing will be to figure out how much content you need to fill out the space. There's not really a good way to do that either since, it will depend on both the markup and the styles.
The best solution I can think of is loading the nodes with javascript, or maybe just have them available as javascript variables. That way you could insert the nodes to your page one by one. You could then in the JS see the heights of all the nodes in total, and once that height is bigger than x, you only need to remove the last inserted node.
It's not a perfect solution, but I think you should look at doing this with JavaScript. The only problem is, that it wont degrade gracefully very well.
Drupal help you build fast, and it looks like promising but fails to fullfil the needs of client, designer also programmer. You need to write one module page, and some functions.
5th solution you gave has little trouble than others. Write a function that to have "teaser like" behavior, I will return formatted node according to its type. Don't lay on drupal's teaser system. If teasers will have different heights, add height to teaser function.
I don't have a direct answer, but have a few things for you to think about.
It sounds to me like what you are looking for is a combination of a CSS3 Multicolumn Layout (see http://www.quirksmode.org/css/multicolumn.html for example) and limiting the displayed content to a fixed height.
My first thought would be to create a single view that gets more than you need, display it using CSS3 columns, and set overflow: hidden; for the container, so that the extra text is just hidden.
If you need to get more particular, you may need to dig in to the views rendering system to limit the total number of nodes based on how many characters have been rendered.
But since your desired constraint is more visual than data-oriented, I think that the most practical approach will be to use javascript to detect the text height and state of overflow.
There are some things that are unclear about your requirements. What is the purpose of the 2 content types? Does one display on the left and the other on the right? Or are these just 2 different content types that should behave the same way, but we're only seeing one content type at a time on a given page? What should happen with the overflowed content? Should it appear dynamically on page 2, then 3, then 4, and so on?
One parting thought: Maybe load ALL the content that you want to page through, directly to the browser. Maybe have it start off hidden. Then use javascript to display it, formatted into columns, and use javascript to handle the paging as well.

How can I change/modify a 3 level hierarchy

I have a table in my database which keeps track of a 3 level hierarchy. What is the best way to display and change/modify this hierarchy? Which asp.net control to use and how?
I can give you some ideas from the little informations that I have.
First in the database, just use a field that point to the father of a line. Using this father ID you can make any simple tree.
The easiest way to modify it is just change this father and take care to not make any dead cycle loop.
Second way is to use jQuery and any Tree control, to modify the tree.
For example this http://www.jstree.com/
or this http://www.prodevtips.com/2010/03/07/jquery-drag-and-drop-to-sort-tree/
are very good jQuery javacript code to show and change the hierarchy.
Using any of this jQuery plugin you can render your tree, and after the modification to get the changes and saved back to your database.

Resources