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

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.

Related

Connecting default theme menu to one-page sections dynamically

Connected to this question: https://wordpress.stackexchange.com/questions/300387/default-menu-items-for-custom-theme-but-easily-delete-able-customize-able-by-u
So, using this bootstrap template as an example again: https://blackrockdigital.github.io/startbootstrap-creative/
the menu items would be connected to the sections so when clicked on they are scrolled to. However, how would I dynamically link in a ux/ui friendly way the menu items to each respective section so that when user goes to change an item or menu they would link back to that section?
In other words, I would have a default easily change-able menu and menu items come with the theme. However, how would I go about making it easy for the user to connect a different menu item to the same section? And how would I dynamically connect a menu item to said section?
Assuming your theme uses the native WordPress menu page for building custom menus for your respective website, this is relatively easy. In order for this to work properly, there will need to be some custom JS added to your page to handle scrolling down to a given section.
Sections themselves will need to also have a unique identifier, so the JS provided can actually scroll to the given section. Here is an example on how to accomplish this:
We will start by creating and editing a WordPress menu. Be sure to set up the links from the menu items so they will work with the upcoming anchor scroll-ability. These url's MUST match the ID of the section on the front-end you are wishing to scroll to.
We now can utilize jQuery to trigger a click function, which will scroll the user down to the respective section on the page. Here's an example of a function you can use. Remember, some formatting of the function will be required as you need to make sure the parent wrapper of your menu has the ID which the function is looking for. Here's the function:
$('#navigation a').on('click', function (e) {
//Stop page from doing default stuff
e.preventDefault();
//Get content panel ID from clicked element
var contentPanelId = $(this).attr("href");
//Animate to clicked element
$('html, body').stop().animate({
scrollTop: $(contentPanelId).offset().top
}, 900, 'swing', function () {
window.location.hash = target;
});
});
Now, to output the menu inside a template, we will go ahead and use the wp_nav_menu() function: https://developer.wordpress.org/reference/functions/wp_nav_menu/ . Be sure to wrap the use of this function around the a parent DIV with an ID matching what's being called inside your JS function (in this example, the ID is "navigation"). Here's an example of the expected markup (remember, I've named my menu menu-test in the back-end):
<header id="navigation" class="site-header" role="banner">
<?php wp_nav_menu( array('menu' => 'menu-test' ) ); ?>
</header><!-- #masthead -->
That should be it! Obviously additional styles are going to be required to lay out the menu however you'd like it to appear on your page. The most important to remember for this concept is that the markup elements' ID's MUST match the hash'ed out URL of the menu item. If there's no div on page with respective ID, the JavaScript will have no way of knowing what element to scroll to.
Here is a live example of the menu functioning the way you want it to on my personal portfolio.

Custom Content Block in Sitefinity

I want to create a custom content block in Sitefinity so I can wrap an tag around it and pick up my CSS.
I created a custom widget, but I'm not sure how to make it a content block. I cannot find documentation on this, but I'm sure it is a common occurrence. Basically, I want a drag out content block that does this:
<aside>
[code for content block]
</aside>
I don't know how to generate the [content block] code in .net. I am new to .net development. I am using VB but can use C#.
Any help would be greatly appreciated. Thank you.
Maria
You can create a custom Layout Control which can be used in conjunction with other controls, such as Content Blocks.
To create a Layout control, open your project in Visual Studio and create a new control (.ascx) file in the WebApp project. I normally put mine in a ~/LayoutControls folder which I create. In that control file, enter something like:
<div runat="server" class="sf_cols">
<aside>
<div id="Div1" runat="server" class="sf_colsIn"></div>
</aside>
</div>
You'll notice that besides the markup you want, the aside tag, I have two other divs with some specifics. These are needed so Sitefinity can treat this as a control, and be able to dynamically inject content into it.
A div with class sf_cols is common to all controls and the div with class sf_colsIn (id="Div1") is where control you drop onto the layout control will go. So there is an outer wrapper div, your markup, and an inner div. It's the inner div where your content will go.
Save your file, compile the project, then register the control in Sitefinity.
To do that, login to the backend then navigate to Administration | Settings | Advanced Settings | Toolboxes | Toolboxes | PageLayouts | Sections. I normally add a new section with these properties:
name=Custom,Title=Custom,Description=Custom Layouts,Global resourceClassId=PageResources
Then select your new section, select Tools, then Create New. The Name, Title, Description are whatever makes sense for you control. The Control CLR Type should be Telerik.Sitefinity.Web.UI.LayoutControl, Telerik.Sitefinity and the Layout Template should be the path to your ascx file, i.e. ~/LayoutControls/AsideBlock.ascx. The other properties can have the default values (most are just blank). Then Save.
Now when you are editing a page, click the 'Layout' button in the right hand column and you will see a 'Custom' Section which contains your control. Drag it onto the page, then go back to 'Content' editing (using the button in the right hand column). You will see your layout control and drop a content block onto it.
Add content normally. When the page renders, the content will be wrapped in the aside tag.
the easiest way to do this is with an external template for the content block. The template you want is ContentBlock.ascx and is in the SDK.
Copy this file to your project then add the wrapping tags around the contentHtml literal control (which renders the actual content of the control).
Then open the Advanced settings of the content block widget you want to use this template and specifiy the LayoutTemplatePath. It should have a default value of something like "~/SFRes/Telerik.Sitefinity.Resources.Templates.Backend.GenericContent.ContentBlock.ascx".
Simply change this to the virtual path to the template you created, then save and publish the page.
The content block will render with your template instead of the default one, with any markup you add.
I hope this is helpful!
I'm going to create a more detailed blog post that walks through this process and will link it here when I'm done. thank you for the inspiration!

ASP.NET implement anchor without postback

I'm working on an ASP.NET web app in VS2010,C#, I want to make something like this page:
http://www.just-eat.co.uk/restaurants-simplyscrumptious/menu
when you click on food categories on left, page jumps to that category without any postback, how can I achieve it?
How to move with out post back
You use the anchor # at the end of the same page url following with the name that you with to move.
Then inside the page you place an anhro with the name that you wish to jump like
<a name="MovePosition"></a>
So if you make a link like http://www.site.com/catalog.aspx#MovePosition the browser will brink the line with the <a name="MovePosition"></a> on top.
reference: http://www.w3.org/MarkUp/1995-archive/Elements/A.html
categories menu always on the same point
If you also notice the categories on the left are stay on the same position. This can be done by many ways. In this specific page is use a script to change his location. How ever the better is to place the categories inside a div and give on this div this extra style position:fixed;bottom:0px; and will stick on the position that you have place it relative to his parent div.
There are many ways to keep the category menu stay on the same point. One other can be found here : http://www.dynamicdrive.com/dynamicindex1/staticmenu.htm even so is old code.
Just addition to the previous answer #Aristos
If on the same page, just do
Go to section 1
If on another page then do
Go to section 1 on another page
Then define the sections with <a name="#sectionName"></a>
<a name="section1"></a>
Thi section 1
content for section 1 follows
<a name="section2"></a>
This section 2
content for section 2 follows

How can I use jQuery tabs for navigation in my ASP.NET MVC app?

I'm creating a new application using ASP.NET MVC.
I'd like to use a series of jQuery tabs at the top of my window to allow the user to access the various modules of the application.
I want to put the tabs in my shared layout view so that I don't replicate them throughout the app.
I'm running into two conflicting issues that I can't seem to find a coherent solution for:
When I click on a tab, I'd like the whole window to navigate to that page, rather than just loading the content into a div. I'm doing this to allow for bookmarking of a particular module. (I'd like the address bar to contain the URL of the current content, rather than just a "main page" URL.)
Currently when I call $("#tabs").tabs(); jQuery creates a div for each of my tabs and attempts to load the content of my href into the div. That ends up creating a copy of the page I'm on nested within itself.
Here are my tab definitions (from the default layout page):
<section class="tabs">
<div id="tabs">
<ul>
<li>Instructions</li>
<li>Questions</li>
<li>Finish</li>
<li>FAQ</li>
</ul>
</div>
</section>
And here's the script I'm using to set them up:
function SetupTabs(sel) {
$("#tabs").tabs();
$("#tabs").tabs("select", sel); // Selects the tab
$('#tabs').tabs({
select: function (event, ui) {
location.href = ui.tab.rel;
}
});
}
This actually gets my page navigating correctly, but nests the pages within themselves (issue #2 above). If I re-arrange it so that I have a main page, and load the content from the tabs using partial views, then I don't have a usable URL in the address bar (issue #1 above).
Any ideas would be greatly appreciated. I know this isn't the design paradigm for the jQuery tabs, but we're using them elsewhere in the app and we use a lot of jQuery UI-themed elements, so I'd like to stick with them for this element, too, if I can make it work.
Thanks
Since you want each tab click to act as navigation, you may want to consider not using the JQueryUI Tabs, instead use a <ul> styled to look like tabs with the click events set to navigate to the pages you'd like.

Link to specific tab in wordpress layout?

I have created a layout in Wordpress with a plug-in called builder. I then have a page that uses this layout. The layout contains a area with tabs.
When the user clicks on a link in my main menu he is taken to this page with the first tab open. Can I change the link to take him to the second tab instead?
Actually the menu looks like this
About us
-Overview
-History
-Contact
If the user clicks on about us or overview I want him to go to the first tab.
I guess you must create something with an HTML anchor OR
$(document).ready(function() {
$('#tabs #2nditemid').click();
});
OR
$(document).ready(function() {
$('#tabs li').hide();
$('#tabs li.2nditemid').show();
});
This may vary a bit but may lead you somewhere
this must be specific only to where you have the tabs... so best is to create a page theme only for this specific page to avoid extra jquery in all pages

Resources