Drupal joining multiple views in master view - drupal

I have multiple views I want to join into the one master view.
View A: List of pages of content type A
View B: List of pages of content type B
I need to join Views A and B into Vew C, which will be the master view accessible via menu.
So far, I have found a module called "Views Field View", which works, but for me only for 50%.
For demonstration, I will add an image, which I will refer to:
The problem is, I cannot call the views A and B into main content - into FIELDS (Red on image).
For some reason, Anything with GLOBAL category will not get displayed.
Sadly, even "Custom text" and "Show" or "Views_field_view" are part of the GLOBAL category.
The only way how it is working now, is adding it as a HEADER (Blue on first image - HLAVIČKA).
So far so good.
But I need also add headers.
Bad thing is, that the inner views are shown without their headers. But in HEADER category on configuration of the view, there is no possibility of adding Global:Custom text, so I cannot add the headers manualy in master view C too...
So, any ideas, how to have
View C{
Header A
View A
Header B
View B
}
Or
View C{
View A{header, content}
View B{header, content}
}
?
Thanks in advance.

Related

Use multiple App Maker fragment forms on the same page

So if I have a customer lookup fragment form (i.e. name to lookup and displays address), then need a page with a from and to customer, is there a way to isolate the data binding so that both can be individual?
Currently I can only get the same data to show up in either and so changing one effects the other.
You can override page fragment's datasource:
Once you check 'Override page fragment datasource' checkbox, datasource property will become editable.
Ah got it! In part to what #Pavel responded with....
So in the fragment, the data source is set up pretty much normally:
In the inserted fragments, settings are as follows:
- over-ride checked
- datasource: #Datasources.Addresses.items
Both fragments now act individually on selected name.

Dynamically changing a portion of a Drupal page based on clicking links from a view

Introduction
I'm a bit new to Drupal, so I'm still trying to wrap my head around how all the different ways of implementing dynamic content work. Let me explain my desired end state and explain some methods I have tried. Also, I'm using Drupal 7.
Desired end state
I want a page that pulls a context argument from the URL to display content (level 1) based on the Taxonomy Term ID in the URL. On this page, fields from the selected content node are displayed and a view displays associated sub-content (level 2) in a grid of icons. When one of the sub-content (level 2) icons are clicked, another region of the page updates with fields from the sub-content (level 2) node that match the icon selected. This pane should update with AJAX to prevent page reloads.
Current design
What I have so far is a PAGE that uses contextual filters to pass the Taxonomy Term ID as an argument in the URL to display the correct page content. This works.
To this page, I have added a panel for the content (level 1) I want to display. Additionally, I added a VIEW panel that displays only the sub-content (level 2) icons associated with the content (level 1). This works.
Attempted solutions
I am at a loss for how to display the NODE content for the selected sub-content (level 2) icon. I made a PAGE with the appropriate arguments to display exactly what I want. The intention being that I would add the PAGE as a panel to the existing PAGE and pass the arguments to this PAGE by rewriting the icon linking and setting the target parameter. I have not found a way to embed a page within a page.
My next thought was to create a VIEW that used contextual filters to display only the NODE content for the selected sub-content, but I haven't found a way to pass the contextual filters from a click of the icon to the VIEW.
Conclusion
I'm sure there are many ways to do this, but I am looking for the least invasive way. What I mean by that, is that I'm looking for a method using existing techniques within panels, panelizer, views, etc. if it exists. As a last resort, any custom code modifications would have to be contained within a module for ease of maintenance. I'm not exactly sure what I'm looking for because the terminology for everything in Drupal is still confusing to me, but some pointers in the right direction would be great.
Here's a mockup of what I'm describing:
I found a method of doing this that is working like a charm.
What I did:
I used Panelizer to modify the appearance of a node of content type 1, and added the fields I wanted displayed.
Next, I created a View for the sub-content icons. One of the fields for the sub-content is an Entity Reference to specific nodes of content type 1. I exploited this reference with a Views Relationship and a Views Contextual Filter to limit the output of my view to sub-content related to the specified node ID. I defined this node ID in the panel settings for the view in Panelizer Content by selecting "Content ID" as the context.
I added the "Nid" (Node ID) field to the view, but excluded the output. Next, I applied a rewrite rule to the Icon field and changed the link path to an absolute path of "ajax-viewer/nojs/[nid]".
Next, I created another view for the full display of the sub-content. I applied the same Views Relationship and Views Contextual Filter as the other view, however I didn't specify the context in the Panelizer Content settings, but I did add a CSS ID. I added a Content Pane to the view and set the name of the pane. Also I turned "Use AJAX" to "On".
I created one more view for the icons of sub-sub-content, but used the entity reference to sub-content instead of content. I also didn't define the context in Panelizer Content, but did define a CSS ID. I made the view a Content Pane and defined the name of the pane.
This set up all of the structure to the page, but I still had to make a module to power the AJAX call. I referenced this page for the idea. However, I made a second helper function for my second view. In Sean's example, the views call (which I used) has to be changed to match the view.
return views_embed_view ('machine-name-of-view','name-of-content-pane-in-view', $nid);
Since one function can only return one value, I modified the ajax_link_response() function a bit...
function ajax_link_response($type = 'ajax', $nid = 0) {
/* These next two lines are different */
$sub-content-output = _ajax_reader_load_noder_sub_content($nid);
$sub-sub-content-output = _ajax_reader_load_noder_sub_sub_content($nid);
if ($type == 'ajax') {
$commands = array();
/* These next two lines are different. The # and id= must match the CSS IDs set in Panelizer Content. */
$commands[] = ajax_command_replace('#sub-content', '<div id="sub-content">' . $sub-content-output . '</div>');
$commands[] = ajax_command_replace('#sub-sub-content', '<div id="sub-sub-content">' . $sub-sub-content-output . '</div>');
$page = array(
'#type' => 'ajax',
'#commands' => $commands
);
ajax_deliver($page);
}
else {
/* These next three lines are different. Same as above with the CSS IDs. */
$sub-content-output = '<div id="sub-content">' . $sub-content-output . '</div>';
$sub-sub-content-output = '<div id="sub-sub-content">' . $sub-sub-content-output . '</div>';
$output = $sub-content-output + $sub-sub-content-output;
return $output;
}
}
One last thing I did was to not include the _init() function in Sean's example as the view was activating AJAX already since I set it on. Including the _init() function caused AJAX on my forms to break.
This set-up works like a charm. One last thing I did was to specify a default Node ID in the Views Contextual Filter for the sub-content and sub-sub-content so that initial content is displayed.

Default.ctp and a totally different login page

Within my default.ctp page I keep navigational and structural content applicable to the entire application. For example menu structures and a column based CSS. I would like to change my login page, however, to look entirely different (no menu, no columns, etc)
Is there a way to load a separate ctp file for a single URL only? e.g. /plugin/controller/login
http://book.cakephp.org/2.0/en/views.html
You can create a new layout for the login page and for that controller/action change the layout name
$this->layout = 'login';
There are two ways. First, you create your new layout file, à la login.ctp inside your View/Layout folder.
Next, in your login action, at the top you can write $this->layout = "login";. The other way you can do it is when you render the view, at the end of your action method, like this: $this->render('actionName', 'login');

Drupal views, get node id from url

I want to make a view, that can show a single blog post. This is to be used in a panel.
Is it possible to create a view, that show a node getting the node id from the url?
I have tried creating a view with :
CONTEXTUAL FILTERS -> nodeid -> WHEN THE FILTER VALUE IS NOT AVAILABLE
->Provide default value -> Content ID From URL
This does not seem to work though, maybe the URL to the panel holding the view is constructed wrong?
1) If the panel page is a node template override it will have no problems and it will work without extra settings (you will see that also when you set the panel pane, there are not extra settings).
2) If not (eg if it is a frontpage panel page) you have to pass the argument from panel to views. The path for that page should have a nid argument or a panel pane may have this. Eg your path may be "home/%node". And you have to add a context to your panel that is of type node. Then Assign the Node: id to this argument.
See a similar discussion at https://drupal.stackexchange.com/questions/63538/how-to-pass-a-nid-to-panel-and-load-a-node-with-the-given-nid-as-context

Drupal: views display as a block; putting inside an html tab

Drupal 6.28:
I'm re-theming a particular section of a site and the new design called for five pages to be displayed as five tabs on one page with the appropriate one shown when either clicking on the tab itself or in an expanded menu to the left.
I created all that in html and jquery so that I could deep-link the tabs, ie... someone can click on any menu link and hit the page with the appropriate tab open instead of having to go to the master page and then click the appropriate tab. (using location.hash)
This is all working fine, but the last tab is to house content that currently is a view set as a block.
What is the best way to pull that view/block into the html div I have set aside for that specific content?
I have used this great snippet before:
<?php
$block = module_invoke('block', 'block', 'view', '15');
print $block['content'];
?>
which allows one to place any block anywhere, but with a view with a display set as a block, I'm not having any luck invoking that view. Also, I'd had to have to use "php" instead of 'full html' on the node since it's just a snippet but as it's not currently working, it probably doesn't matter.
so, I'm trying to figure out how to have something like this:
<!-- all the other tabs content-->
<div id="fifthTab">
all the content from the view which is set to 'display like a block'
</div>
I'm fairly new to Drupal and not even sure if I create a page display how I would call that data anyway.
So my html structure is:
MAIN PAGE LINK
-sub link/tab 1/default
-sub link/tab 2
-sub link/tab3
-sub link/tab4
-sub link/tab5
So if someone either clicks on on the sub link/tab 5 in the left nav or clicks on the actual tab 5 or enters the url xxx/#tab5, the appropriate tab is show, the rest hidden. That's all working great, I just cant get the view content to show in that tab5.
so a page template based on the url is the easiest. The variable $content is just placed in the last tab and all other html content for that specific page is just put in the template.
At least this way, as docs are added, it's still dynamic and the static info is easy to edit if needed.
Just in case something similar comes up for someone else.

Resources