Jump to content
  • 0

Page Elements to Tab Element


jaxincb

Question

I have been working with Tab Elements, I sometimes try to move a page element into an inner Tab by dragging it, like is common in most of the website. But it won't go, until I first create a Page Element within the destination, then dragging into the Tab Element works fine.

 

Is this the best practice for moving elements into a Tab Element? Does anyone else have this issue? ...or have a better way?

Link to comment
Share on other sites

14 answers to this question

Recommended Posts

Hi jax, I'm pretty sure you have discovered the best workaround for dragging page elements into previously empty tabbed elements. I have heard of users creating a text block element, putting a few XXs in the text block, then saving it in a previously empty tab element. Then they drag in the desired page element and delete the text element. Not ideal, but it works.

 

I'll see if Sitebuilder product manager Rob Bedeaux has any other information on this topic.

Link to comment
Share on other sites

Take a look at dragging elements out of a tab element too.

 

I get around that by clicking the "Move" icon and moving the page to the same page the tab element is on. It comes in at the bottom of the page and I then drag it to where I need it.

 

"Not ideal, but it works."

Link to comment
Share on other sites

How do you link to an individual tab?

Let's say I have a page called Hockey. On this page I have a tab element with 3 tabs entitled: Overview, Division A, and Division B. When I go to the Hockey page (in User mode), the Overview tab is automatically selected (this is default), all good there. I also have a few text links on the Overview tab, cleverly called Division A and Division B of which currently point to a named anchor set at the top of each tab. Here's a rough example of what I'm looking to do.

Page: Hockey
URL: /hockey (aka: /hockey#overview)
Tabs: Overview (active tab) | <a href="#div-a">A-Division</a> | <a href="#div-b">B-Division</a></p>
H2: <a id="overview" name="overview"></a>Overview
P: Overview tab content... we have 2 divisions, <a href="#div-a">A-Division</a> and <a href="#div-b">B-Division</a> ...

Page: Hockey
URL: /hockey#div-a
Tabs: <a href="#overview">Overview</a> | A-Division (active tab) | <a href="#div-b">B-Division</a></p>
H2: <a id="div-a" name="div-a"></a>A-Division
P: A-Division tab content... or read about the <a href="/hockey#div-b">B-Division</a> ...

Super-duper pseudo-code aside, it would be wonderful if the above concept itself actually worked ... but it does not. While in User mode, if I right-click on my Division B tab and select "copy link address", I get something like this:
/layout_container/show_layout_tab?layout_container_id=16729545&page_node_id=1052233&tab_element_id=54295

...however, updating my text links (or simply visiting this URL) only shows me the un-styled content of the tab I right-clicked on. Not too helpful.

And so...
My question is, how do I actually link to an individual tab from another tab or another page altogether?

Thoughts, tips or tricks?

Thanks,
_rs

Link to comment
Share on other sites

Hi there,

 

There isn't a built in way to set the tab when a page loads, but with a little Javascript magic, you can accomplish this. It isn't pretty, but here you go!!

 

Take the code block below and insert it onto the page (I like sticking it on a tab in the tab element so it doesn't get 'lost.'

 

You can now use a query string in the URL to target a specific tab. For example, if I have a tab with three tabs called Red, Blue, and Yellow and I want to target the tab yellow I would input in the URL something like this http://www.mysite.com/mypage/?tab=Yellow.

 

A couple of notes—if you have multiple tabs with the same name, it will set them all to the same tab. Set the Code Element title so you remember what this does!

 

<script>

function getParameterByName(name) {

name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");

var regex = new RegExp("[\\?&]" + name + "=([^]*)"),

results = regex.exec(location.search);

return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));

}

$j(window).load(function() {

var selectedTab = getParameterByName("tab");

if (selectedTab !== "") {

$j("ul.layoutContainerTabs span a:contains(" + selectedTab + ")").click();

}

})

</script>

Rob Bedeaux (he/him/his)
Director, Partnerships & Symphony Marketing
E rob.bedeaux@nbcuni.com

NBC SPORTS NEXT & FANDANGO

Link to comment
Share on other sites

Excellent! Worked like a charm.

 

A couple notes for anyone following along or using the script listed above:

 

  1. Be sure to clear the cache (both from your browser and the Sport Ngin page you just added this code to), otherwise it'll look like it doesn't work.
  2. The query string is case-sensitive. In this case, linking to http://www.mysite.com/mypage/?tab=Yellow will work just fine while http://www.mysite.com/mypage/?tab=yellow will bonk. That is, unless you actually named your tab "yellow" (in lowercase).
I can see this little trick being another candidate for one of Brian's training videos.

 

Thanks again!

_rs

Link to comment
Share on other sites

I did some testing on this on a couple of the sites I spend a lot of time working on.

 

On one, a custom theme, I wasn't able to drag elements into the tab element no matter what I tried.

 

On the other, also a custom theme, I had no problem dragging in elements once I had created that first element inside the tab (as discussed in original post). I was unable to drag elements out of the tab element, though.

 

So, it might depend on the theme you are using?

 

Curious to hear other folks' experiences trying this.

 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...