I created a view with a page display and a block display.
(1) The page view displays several content "A" with a pager (one full content by "page of pager"). ( in drupalsite/myview )
(2) The block shows the liste of content "A". (put in drupalsite/myview )
This is very simply.
Now I have my page (drupalsite/myview) with : the block view (1) and the view pager (2). When I click on a number X of the pager widget, the view display the content number X (drupalsite/myview?page=X) but when I click on one content in the block view the page load (goto drupalsite/node/X) and display only the content (there is no longer the view with the pager)
How can I do that ?
If I click on the item in the block view, the user isn't redirected to the node page. Instead, the view pager refresh, I mean :
In the block view, I click on a item, I go to drupal/myview?page=X (not drupalsite/node/X). The view module can manage that or I must create a custom module ?
Yes it is possible.
1) Install View Path http://drupal.org/project/views_php
2) Add a Global PHP field
3) In the output Code box put
<?php
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
echo $actual_link;
?>
4) In the 'Rewrite Results' check 'Rewrite the output of this field' and put [title] in the Text box
5) check also 'Output this field as a link' and in link path put [php]
6) Go to your 'Fields' Content: Title and check 'Exclude from display'
In this way, your title of the contents will be replaced by the Global: PHP field which content is the title of the node and which link is the current url.
Related
I have a view block of content type "Career". I want to show a custom block when the "Career" is empty.
I tried to add in "NO RESULTS BEHAVIOR" a field (Global: Rendered entity - Custom block (Global: Rendered entity - Custom block) and I typed the id of the custom block.
- The content of custom block is shown in the view block, but I don't know why when I reload the page, I got nothing in place of view block.
What should I do?
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.
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.
I am placing a form inside a block in drupal with the following code
function current_posts_block_view($delta = '') {
$elements = drupal_get_form('mydeveloper_simple_form');
$block['content'] = drupal_render($elements);
}
This block is displayed in footer. The form has required field validator in it. So if I submit the form with no data the validator will work and error is displayed, in the default place in the node where the error will get displayed. (on the top of the page)
I want it to be displayed inside my block. What should I do for that?
The reason is that, all errors, information, and status messages are displayed where you have set in the page.tpl.php in your theme.
You can try Inline Form Errors module, http://drupal.org/project/ife/ , to fix this.
I'm using Drupal 6 views to create pages. I would like the page title to be whatever the user selects from an exposed filter I'm using. How do I get the selection from the exposed filter to be the page title? I've inserted the following php code into the header window, and selected php as the input. The result is that the page is titled Program:
Thank you for your help.
<?php
$view = views_get_current_view();
$program = $view->exposed_input[field_program_value] ;
drupal_set_title('Program: '. $program->title);
?>
Use form alter and set page title using drupal_set_title() in that. add condition for $_GET or $_POST to avoid setting title when no filter selected.