Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is how I would approach this problem based on how you have described it. The majority of the functionality being handled by the Views module.</p> <p>I'm assuming you have the following setup:</p> <ul> <li>A Taxonomy vocabulary called "companies" which has company names as terms.</li> <li>A Content Type called "News", which has news information about companies. Most importantly it will need a taxonomy field where you can select which companies it is related to (lets call this field "company_reference")</li> <li>A Content Type called "Tables"(?). I'm not sure what information you want in your "tables", but again it's most important that is has a taxonomy field to reference companies. (can be the same field "company_reference")</li> </ul> <p>The Majority of the functionality you are looking for can be built using the Views module.</p> <p>I would create a View (let's call it "Company Data"). the view is going to have three different displays, each of type "block".</p> <p>Display 1: <strong>Input Block</strong></p> <ul> <li>Set the display name to something meaningful, say "user_input_block"</li> <li>For this block, leave <strong>FORMAT</strong> settings as they are.</li> <li>For the <strong>FIELDS</strong> settings, just have "Content: Title" (does not really matter for this block).</li> <li>For the <strong>FILTER CRITERIA</strong> settings, add a filter and select your "company_reference" field, set it to auto-complete, expose the filter to visitors and (under the "more" section) change its Filter Identity to "company".</li> <li>For the <strong>PAGER</strong> settings set it to display a specific number of items and set it to '1'. (this will limit the data this block retrieves)</li> <li>Under the <strong>Advanced</strong> section change the "Machine Name" so comething meaningful, say "user_input_block"</li> <li>Still in the <strong>Advanced</strong> section click on "Theme: Information". this will display a list of the different custom template files you can have for this view. For "Display Output" write down the last template suggestion in the list, it will be something like "views-view--company-data--user-input-block.tpl.php" ("views-view--{your view name}--{your display name}.tpl.php"). Click on "Display Output" and copy the PHP it lists. (this is the views default PHP for the view).</li> <li>In a text editor/IDE (whatever you use) paste the copied PHP code and save it in your custom theme with the template name you wrote down. Edit the PHP and either comment out or remove the section that says "<code>&lt;?php if ($rows): ?&gt;...&lt;?php endif; ?&gt;</code>" (this will remove the returned content from the display)</li> </ul> <p>So to review the view display that was just created will (using the custom template) display a block with just a field that as the user is entering a company name it will autocomplete. It will then submit the form and pass it as a GET variable to the current url (www.yoursite.com/yourpage?company=users company").</p> <p>Display 2: ** Main Block**</p> <ul> <li>Set the display name to something meaningful , say "company_news".</li> <li>Set the <strong>FORMAT</strong> settings to which ever you like (or leave as is)</li> <li>For the <strong>FILTER CRITERIA</strong> add a "Content:type" filter and select your "News" and "Tables" content types.</li> <li>In the <strong>Advanced</strong> section click "add" next to "Contextual Filters". )A contextual filter is passed in the URL, we are going to be grabbing the value that was passed from the Input block.) Select "Content: field_company_reference" as the field and click "Apply"</li> <li>for the "when the Filter value is Not available" section select "provide default value"</li> <li>for the "Type" select "PHP code" and the PHP code will be something like this "<code>return isset($_GET['company']) ? $_GET['company']:false;</code>"</li> <li>for the "When the filter is available of a default is provided", check "Specify validation criteria", set "Validator" to "Taxonomy term", check the "Companies" vocabulary and for "Filter value type select "Term name converted to Term ID"</li> <li>for "action to take if filter value does not validate" select "display all results"</li> </ul> <p>To review, this view display will display a block that lists "news" and "tables" content. If the GET variable "company" is passed (from the input block) then the content of this block will be filtered to display only content that is associated to that block.</p> <p>Display 3: ** Graph Block**</p> <p>I'm not exactly sure what data you want to display in this block (or rather where it would be coming from) but if you set it up like how I described setting up the <strong>Main Block</strong> it will filter by company (use the same contextual filter and content that has the company taxonomy reference field).</p> <p>The one difference with this approach is that it requires the page to be reloaded when a user enters a company into the input block. If you want to avoid this then you could make the following changes;</p> <ul> <li>for the <strong>main block</strong> and <strong>graph blocks</strong> instead of using a contextual filter use a regular filter for the Company reference field (same settings as were setup in the input block). For both these blocks under the <strong>Advanced</strong> section, set "Use AJAX" to "Yes", and use custom CSS to hide the exposed filters from view.</li> <li>with a custom module (or with your custom theme) that adds additional JS to the page. Have the JS triggered by the field in the <strong>input block</strong>, when a user enters a value into it, the JS copies that value into the exposed (but hidden) field for the other blocks, triggering Drupal to reload them via AJAX with the passed filter.</li> </ul> <p>I haven't tested any of this and it is just theoretical based on my knowledge of Drupal, but it should start you out on the right path.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload