Jump to content


Photo

Help with jQuery tab content


  • Please log in to reply
3 replies to this topic

#1 darren

darren

    Likes Etomite Forums!

  • Member
  • PipPip
  • 251 posts

Posted 29 July 2010 - 07:29 PM

I have a snippet that takes unpublished child documents and generates the html necessary for the jQuery tab widget. The issue i have is that any uncached snippet calls in the child documents are being displayed as text (what displays is [!snippetcall!]) For my immediate need we'll just be placing basic content in the tabbed areas but I can see this being used in other ways so maybe you all can assist?

I'm sure it's something easy i've overlooked - something in the back of my head says this has come up before. The snippet is very basic:

if (!isset($thispage)) {
$thispage = $etomite->documentObject['id'];
}
$tabs = $etomite->getIntTableRows(
$fields="id, pagetitle, content",
$from="etomite_site_content",
$where="parent = $thispage AND published = '0' AND deleted = '0' AND authenticate = '0'",
$sort="menuindex",
$dir="ASC",
$limit="",
$push=true); 


if($tabs){

$output .="<div id='tabs'><ul>";

foreach($tabs as $row)
{ 
$output .="<li><a href='#tabs-" . $row['id'] . "'>" . $row['pagetitle'] . "</a></li>";
} 
$output .="</ul>";

foreach($tabs as $row)
{ 
$output .="<div id='tabs-" . $row['id'] . "'>";
$output .= $row['content'];
// i guess i need something here to run un-cached snippets...
// instead of just outputting $row['content']
$output .="</div>";
}
$output .="</div>";

}
	
		
return $output;

thanks in advance :)

#2 Ralph

Ralph

    Loves Etomite Forums!

  • Admin
  • 6,539 posts

Posted 29 July 2010 - 07:44 PM

If your snippet and jQuery code is configured properly you should be getting fully parsed content back from Etomite... I think it is your logic that is flawed... You cannot pull content from the database and expect it to include other resource content that requires parsing to fill... What you need is a method of using XMLHttpRequest to grab the content for the tabs, using an Etomite page template that only contains the [*content*] tag, and perhaps the [!DontLogPageHit!] snippet call for statistics purposes... I have an example on my webpage but it appears to be broken at the moment... HERE is a link to the fixed page... Also check THIS as well as it is the JS that powers things...

Actually, I have done this using at least one 3rd party jQuery plugin as well... I can't think of the code right now but I'll try to dig around for it when my eyesight snaps back into focus... So I know it can be done more than one way...

Most jQuery tab code allows the tab body to be filled using an XLMHttpRequest call...

#3 darren

darren

    Likes Etomite Forums!

  • Member
  • PipPip
  • 251 posts

Posted 30 July 2010 - 12:53 PM

Ralph,
everything gets parsed but the un-cached snippets. I'll have a look at the links you posted; thanks for the direction.

you are correct about the logic, this started out as a method to put copy (text only content) in the tabbed area but now i can see that it will be more than that. that's what happens when idea/projects change direction...

darren

#4 darren

darren

    Likes Etomite Forums!

  • Member
  • PipPip
  • 251 posts

Posted 30 July 2010 - 04:51 PM

Some time with Google (jquery tabs + XMLHttpRequest) and the answer showed up. If I initialize the tabs like so:

$("#tabs").tabs({remote:true});

and modify the snippet to link to the file on a blank template like you suggest...

if (!isset($thispage)) {
$thispage = $etomite->documentObject['id'];
}
$tabs = $etomite->getIntTableRows(
$fields="id, pagetitle",
$from="etomite_site_content",
$where="parent = $thispage AND showinmenu = '0' AND deleted = '0' AND authenticate = '0' AND published = '1'",
$sort="menuindex",
$dir="ASC",
$limit="",
$push=true); 


if($tabs){

$output .="<div id='tabs'><ul>";

foreach($tabs as $row)
{ 
$output .="<li><a href='index.php?id=" . $row['id'] . "'>" . $row['pagetitle'] . "</a></li>";
} 
$output .="</ul></div>";

}
	
		
return $output;

It works! Thanks Ralph for pointing me in the right direction.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users