HowTo: 1. mosTabs and 2. patTemplate in combination

A general technical discussion area for patTemplate.
Locked
User avatar
musicones
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 176
Joined: Fri Aug 19, 2005 5:52 am

HowTo: 1. mosTabs and 2. patTemplate in combination

Post by musicones » Wed Oct 19, 2005 5:10 pm

Hi,

1. I want to use tabs in an component like they are used in 'Global configuration'
2. I want to combine the use of the tabs with patTemplates.

I found out following for the tabs:

A new Tab Reference: $tabs = new mosTabs(1);

Whats this? $tabs->startPane("configPane");
First tab? $tabs->startTab("Site","site-page");
End of Tabs $tabs->endTab();

seems to be like using for toolbar, start, first, next, end.

How should it look for more than one tab, do I have to repeat $tabs->startTab("Site","site-page"); with different values?


I'm using patTemplate for Output. Is it possible to mix tabs and templates?
I've made some easy template outputs with text and vars.

regards
musicones

User avatar
musicones
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 176
Joined: Fri Aug 19, 2005 5:52 am

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by musicones » Thu Oct 20, 2005 12:21 pm

If found out myself some things and could generate a tabbar with 5 tabs.

Here some example code to generate tabs without content:

Code: Select all


// instantiate new tabbar
$tabs = new mosTabs(1);

// start Tabbar
$tabs->startPane("Mytabbar");

First tab
$tabs->startTab("My first tab","myfirsttab-page");
// here comes the content
$tabs->endTab();

$tabs->startTab("My second tab","mysecondtab-page");
// here comes the content
$tabs->endTab();

// start Tabbar
$tabs->endPane("Mytabbar");
regards
musicones

User avatar
musicones
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 176
Joined: Fri Aug 19, 2005 5:52 am

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by musicones » Thu Oct 20, 2005 6:21 pm

Hello again,

some explanation and Question:

I'm working on a component and want to use patTemplate in backend.
Some things work already.

But how far can I use Joomla Objects with patTemplate?

Example:
When you click in backend on components and then on the componentname
you should see the configuration of the component with 5 tabs.

For now I'm doing this with mosTabs in admin.componentname.php

The sense is to seperate Output from logic so I think the output of the tabs should move into the template.
Is that possible and how?

At the present I've got problems that maybe exist because of that circumstance.
I fill a tab with a fix about text and an var that ist filled before and put it into the template.
That works great.

An other tab should show an file content in an textarea, so that it can be edited
This works also, but when I do that I can't click on on the 'cancel' Button anymore.
Nothing happens.

I've got developer tools in Firefox and it shows me following error message:

Error: document.adminForm.task has no properties
Source: http://localhost/joomla/includes/js/joo ... ascript.js
Zeile: 349

Could someon help me fix it?


thanks and regards
musicones

alwarren
Joomla! Guru
Joomla! Guru
Posts: 527
Joined: Fri Aug 19, 2005 9:27 am

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by alwarren » Fri Oct 21, 2005 5:47 am

musicones wrote:I've got developer tools in Firefox and it shows me following error message:

Error: document.adminForm.task has no properties
Source: http://localhost/joomla/includes/js/joo ... ascript.js
Zeile: 349

Could someon help me fix it?
Make sure you have a hidden form element for task:

Code: Select all

<input type ="hidden" name="task" value="{TASK}">
Note that {TASK} is a patTemplate variable in this case.
Al Warren
This ain't my first rodeo. Red Foreman says it best.
CQDX de WR5AW

User avatar
ianmac
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4784
Joined: Sat Sep 24, 2005 11:01 pm
Location: Toronto, Canada

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by ianmac » Sat Oct 22, 2005 4:40 am

I am also interested in an answer to this question...  What is the best practice for setting up tabs inside a patTemplated document?  On the one hand, it seems like it should be set up as a template, but on the other hand, there is a built in function in Joomla.  It seems like one should take advantage of the api...  Will some of these functions be deprecated as versions go on?

Ian

User avatar
musicones
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 176
Joined: Fri Aug 19, 2005 5:52 am

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by musicones » Sat Oct 22, 2005 5:27 am

Hi again,

I'm on the BERLINUX (you could say an "Berlin Expo"  :laugh:).
I had and have the chance to talk with Predator (Marko Schmuck, core-member) here.

He told me two possible possibilities to that:

1. addObject, an function from patTempate like addVar to add the whole mosTab Object in to the patTemplate
  I've got an example here, but hadn't the possibility to take a look at because of BERLINUX.

2. There must be an possibility to add tabs in patTemplate directly. He didn't know the right function at the moment.
    I will take a look later on this too.

regards
musicones

alwarren
Joomla! Guru
Joomla! Guru
Posts: 527
Joined: Fri Aug 19, 2005 9:27 am

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by alwarren » Sat Oct 22, 2005 6:10 am

I Just began working on a backend component config using patTemplates and tabs. It's pretty straight forward. If you use patFactory, you'll have a large list of standard templates to call. You can get a list of the available templates by doing a $tmpl->dump(); Here's some basic code for setting things up:

Code: Select all

	function config( &$ecTrader ) {
		global $mosConfig_live_site;
		require_once( $mosConfig_absolute_path . '/includes/patTemplate/patTemplate.php' );
		
		$tmpl =& patFactory::createTemplate( $option, true, false );
		$tmpl->setRoot( dirname( __FILE__ ) . '/tmpl' );

		$file = $ecTrader->_lang . ".config.tmpl.html";
		$tmpl->readTemplatesFromInput( $file );
		$tmpl->addObject( 'main', $ecTrader, 'obj_' );

		$tabs = new mosTabs(1); unset($tabs);
		$tmpl->displayParsedTemplate( 'main' );
		return;
	} // end function config
I had some trouble getting the include-tabs template to work. So I wound up creating a new mosTabs object. The constructor creates the needed scripts and css links so it worked out ok. Everything else can be called as a template. You can also setup overlib pretty easy. Here's some template code I used:

Code: Select all

<mos:tmpl name="main">
<mos:Call template="include-overlib"/>

The left side of the screen goes here.

Next, create a tab pane and a tab...

<mos:Call template="starttabpane" paneid="1" panecookies="0"/>
<mos:Call template="starttab" paneid="1" tabtitle="Global/Users"/>

Some tab stuff goes here

Next, close the tab and start a new one...

<mos:Call template="endtab"/>
<mos:Call template="starttab" paneid="1" tabtitle="Public"/>

Some tab stuff goes here

We're done so close the tab and tab pane

<mos:Call template="endtab"/>
<mos:Call template="endtabpane"/>
</mos:tmpl>
That's pretty much it. Very simple, works great, and looks nice.
Last edited by alwarren on Sat Oct 22, 2005 6:18 am, edited 1 time in total.
Al Warren
This ain't my first rodeo. Red Foreman says it best.
CQDX de WR5AW

User avatar
Hackwar
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3788
Joined: Fri Sep 16, 2005 8:41 pm
Location: NRW - Germany
Contact:

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by Hackwar » Fri Oct 28, 2005 10:21 pm

This may sound silly, but I would like to use the nice buttons of the tab-pages on a page for navigation without the hidden page stuff. Just the tabs with links behind them. I experimented a lot allready, but it wont work. somehow I just get a big heading, but no tabs. Which css do I have to add? Or are there any functions that provide the tabs without the simultaneously loaded pages. (Did I make sense in any way? Its late... I think I should sleep.) If anybody knows what I mean and could help me, I would be very grateful.
Hackwar
god doesn't play dice with the universe. not after that drunken night with the devil where he lost classical mechanics in a game of craps.

Since the creation of the Internet, the Earth's rotation has been fueled, primarily, by the collective spinning of English teachers in their graves.

alwarren
Joomla! Guru
Joomla! Guru
Posts: 527
Joined: Fri Aug 19, 2005 9:27 am

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by alwarren » Sat Oct 29, 2005 4:25 am

There is an admin template that is supposed to load the tabs js and css but I couldnt get it to work. I had to do this just before I displayed my template to make tabs work:

$tabs = new mosTabs(1); unset($tabs);

It basically does the same thing as the includeTabs template - it dumps some js and css. See my previous post on how I make it work.
Al Warren
This ain't my first rodeo. Red Foreman says it best.
CQDX de WR5AW

User avatar
musicones
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 176
Joined: Fri Aug 19, 2005 5:52 am

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by musicones » Tue Nov 01, 2005 2:23 pm

Hello again,

@alwarren: your tip works great. :D

Now I've got an other small problem.

I've separated my templates in different files:

main.tmpl
footer.tmpl
about.tmpl etc.

In main.tmpl I have one template where I create header and tabs. The content of the tabs are
separated in other template files.

I've got an tab about and in this tab I load it's template:



Now this template needs an variable to load an copyright text.

Before I loaded the template directly in php like I do with main.tmpl. Now I load the template as subtemplate of main.tmpl.
How to give it a variable?

I tried this for main.tmpl

// variablen übergeben
$tmpl->addVar( 'body', 'Copyright', $Jl_Copyright );
                     
$tmpl->displayParsedTemplate( 'form' );

and then I called the subtemplate like this:




That doesn't work.
Some Ideas?

regards
musicones

User avatar
Predator
Joomla! Ace
Joomla! Ace
Posts: 1823
Joined: Wed Aug 17, 2005 10:12 pm
Location: Germany-Bad Abbach
Contact:

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by Predator » Tue Nov 01, 2005 2:33 pm

Have you tried:

/ variablen übergeben
$tmpl->addVar( 'about', 'Copyright', $Jl_Copyright );

And where is the template form?

$tmpl->displayParsedTemplate( 'form' );

should it not be

$tmpl->displayParsedTemplate( 'about' );
The "Humor, Fun and Games" forum has  more than 2500 Posts, so why not build a "Humor, Fun and Games Working" Group?
.....
Malicious tongues say we have this WG right from the start, they call it core team :D

User avatar
musicones
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 176
Joined: Fri Aug 19, 2005 5:52 am

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by musicones » Tue Nov 01, 2005 2:54 pm

Hi,

I do this in admin.componentname.php:

  // Show J!Legal config
  JlegalScreens::showMain($Jl_Copyright);

I've changed my function showMain($Jl_Copyright)  into this:

Code: Select all

        // Import body of site
        $tmpl =& JlegalScreens::createTemplate();
        $tmpl->setAttribute( 'body', 'src', 'main.tmpl' );
        
		// initialise tabs
		$tabs = new mosTabs(1); unset($tabs);
		
		// add vars to template
		$tmpl->addVar( 'body', 'Copyright', $Jl_Copyright );
		                       
        $tmpl->displayParsedTemplate('main');  


and the main.tmpl file:

Code: Select all

<mos:tmpl name="main">
	<font class='small'>© Copyright 2005 <a href='http://hilfe.joomla.de/' 
		  target='_blank'>Antonio Cambule</a><br />Version: 1.0</font><br/>
	<img src="components/com_Jlegal/images/logo.png"><br/><br/>

	<mos:Call template="starttabpane" paneid="1" panecookies="0"/>
		<mos:Call template="starttab" paneid="1" tabtitle="Address"/>

			Tab für die Adressdaten

		<mos:Call template="endtab"/>

		<mos:Call template="starttab" paneid="1" tabtitle="Contact"/>

			Tab für die Kontaktdaten

		<mos:Call template="endtab"/>

		<mos:Call template="starttab" paneid="1" tabtitle="Bank"/>

			Tab für die Bankdaten

		<mos:Call template="endtab"/>

		<mos:Call template="starttab" paneid="1" tabtitle="Legal"/>

			Tab für die Impressumdaten

		<mos:Call template="endtab"/>

		<mos:Call template="starttab" paneid="1" tabtitle="Footer"/>

			<mos:tmpl name="footer" src="footer.tmpl" parse="on"/>

		<mos:Call template="endtab"/>

		<mos:Call template="starttab" paneid="1" tabtitle="About"/>

			<mos:tmpl name="about" src="about.tmpl" var="{COPYRIGHT}" parse="on"/>

		<mos:Call template="endtab"/>
	<mos:Call template="endtabpane"/>
</mos:tmpl>

Calling $tmpl->displayParsedTemplate('main');  does not work, even if template is named:
I get this error: pat-Warning: Template 'main' does not exist.

if I use $tmpl->displayParsedTemplate('form'); works, even if template is named:

Why? I don't know.

That is maybe one problem.
The next one is that I don't know how to call an other template in main.tmpl with an variable set to main.tmpl. see line:



thanks
musicones

User avatar
Predator
Joomla! Ace
Joomla! Ace
Posts: 1823
Joined: Wed Aug 17, 2005 10:12 pm
Location: Germany-Bad Abbach
Contact:

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by Predator » Tue Nov 01, 2005 3:54 pm

There are a lot of changes between the current patTemplate and the patTemplate 4.5.3 CVS so $tmpl->displayParsedTemplate( 'form' ); is now right in the 4.5.3 CVS not.

I have to make a deep look in the differents :D 
Last edited by Predator on Tue Nov 01, 2005 5:14 pm, edited 1 time in total.
The "Humor, Fun and Games" forum has  more than 2500 Posts, so why not build a "Humor, Fun and Games Working" Group?
.....
Malicious tongues say we have this WG right from the start, they call it core team :D

alwarren
Joomla! Guru
Joomla! Guru
Posts: 527
Joined: Fri Aug 19, 2005 9:27 am

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by alwarren » Wed Nov 02, 2005 4:57 am

Post your createTemplate() function. You need to make sure you're using $tmpl->setRoot to set the base directory to your template folder. Then use $tmpl->readTemplatesFromInput( 'main.html' ); to read your template file.

Here's how I do it:

Code: Select all

	function &createTemplate() {
		global $mosConfig_absolute_path;
		require_once( $mosConfig_absolute_path . '/includes/patTemplate/patTemplate.php' );

		$tmpl =& patFactory::createTemplate( '' );
		$tmpl->setRoot( dirname( __FILE__ ) . '/tmpl' );

		$options = array(
						'output-xhtml' => true,
						'clean'           => true
						);

		$tmpl->applyOutputFilter( 'Tidy', $options );

		return $tmpl;
	}

	$tmpl =& createTemplate();
	$tmpl->readTemplatesFromInput( 'main.html' );
	$tmpl->displayParsedTemplate( 'main' );

Al Warren
This ain't my first rodeo. Red Foreman says it best.
CQDX de WR5AW

User avatar
musicones
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 176
Joined: Fri Aug 19, 2005 5:52 am

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by musicones » Wed Nov 02, 2005 6:59 am

Hi,

Code: Select all

    /**
     * static method to create template object
     * @return patTemplate
     */
    function &createTemplate() {
        global $option, $mosConfig_absolute_path;
        require_once( $mosConfig_absolute_path
            . '/includes/patTemplate/patTemplate.php' );
 
        $tmpl =& patFactory::createTemplate( $option, true, false );
        $tmpl->setRoot( dirname( __FILE__ ) . '/tmpl' );
 
        return $tmpl;
    }

    
    /**
     * show Configuration screen
     * 
     */
    function showMain( $Jl_Copyright ) {
        // Import body of site
        $tmpl =& JlegalScreens::createTemplate();
        $tmpl->setAttribute( 'body', 'src', 'main.tmpl' );
        
		// initialize tabs
		$tabs = new mosTabs(1); unset($tabs);
		
		// Add vars
		$tmpl->addVar( 'body', 'Copyright', $Jl_Copyright );
		                       
        $tmpl->displayParsedTemplate('form');
    }    
That is what I do.

alwarren
Joomla! Guru
Joomla! Guru
Posts: 527
Joined: Fri Aug 19, 2005 9:27 am

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by alwarren » Wed Nov 02, 2005 10:37 am

Here's an abbreviated step-by-step of how your script works with displayParsedTemplate('form'):

1. You create a patFactory Object.
2. The patFactory constructor loads the J! page.html template file and adds some global variables. At this point, the only templates that exist are those within page.html.
3. You set the source for the body template to main.tmpl.
4. You add a copyright variable to the body template.
5. You display the form template.

The displayParsedTemplate function name is a bit misleading. The templates haven't actually been parsed at this point. Parsed means 'get the output'. They are parsed from within the displayParsedTemplate function and then the output is displayed. When you call displayParsedTemplate, the only templates that exist at that point are the ones read from page.html. That's why displayParsedTemplate('main') doesn't work. It doesn't exist - yet. When the templates are parsed, the reader picks up the source for the body template and parses main.tmpl. Since there are templates within main with source attributes, they also have their associated files loaded and parsed.

You can use displayParsedTemplate('main') but you have to first read its templates from main.tmpl using readTemplatesFromInput. The only problem with that is, you've set the body template source to main.tmpl. When the body template (main.tmpl) gets parsed, pat picks up all its subtemplates. Then when you readTemplatesFromInput('main.tmpl'), pat sees another template named main. It also sees all those subtemplates within main. So you get warning messages about each template in main.tmpl. The template is still displayed, but you will have those annoying warning messages. In effect, you've tried to load all the main.tmpl templates twice - once when you set the body template source to main.tmpl and it gets parsed and again when you read the main.tmpl file with readTemplatesFromInput.

The solution is to not set the body source to main.tmpl. Then you read main.tmpl with readTemplatesFromInput and use displayParsedTemplate('main').

There are a couple of side-effects from not using 'form'. Template 'form' displays the form tags for your input form. If you bypass 'form' by manually displaying 'main', you have to add the form tags to your main template. Also, the form template autoloads the body template. You added your copyright variable to the body template. Since the form template isn't loaded, the body template isn't loaded either and you lose the copyright variable. The solution to that is to add the copyright variable to either main or about.

Try it both ways. Use 'form' and look at the source in your browser. Then use 'main' and look at the source. You should notice the form tags when using 'form'. Also, insert $templ->dump() after displayParsedTemplate and spend some time looking at the J! templates and how they are setup. You might also want to take a look at page.html in includes/patTemplate/tmpl just to get a feel for things.

There is one correction to main.tmpl you need to make. In your main.about template, instead of 'var="{COPYRIGHT}"', use 'varscope="body"' or 'varscope="main"' depending on where you add the copyright variable.

Hope this helps. Post again if you have problems.
Last edited by alwarren on Wed Nov 02, 2005 10:40 am, edited 1 time in total.
Al Warren
This ain't my first rodeo. Red Foreman says it best.
CQDX de WR5AW

User avatar
musicones
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 176
Joined: Fri Aug 19, 2005 5:52 am

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by musicones » Mon Nov 07, 2005 10:13 am

Hi,

a bit lately, but better then never: Thank you.

With your help I could realise mosTabs in patTemplate.
I prefered to use it with 'forms'.

regards
musicones

User avatar
Sergey Romanov
I've been banned!
Posts: 279
Joined: Thu Dec 01, 2005 11:32 am
Location: Kyrgyzstan
Contact:

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by Sergey Romanov » Sun Jan 08, 2006 7:56 am

Thank you all

This is very helpful topic. I like using Pat & mosTabs togather  :laugh:

domengph
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Wed Dec 07, 2005 3:18 am

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by domengph » Thu Apr 20, 2006 6:08 pm

Hi!

I've been following the instructions posted in this thread and it's been a very big help in getting our hands on mosTabs and patTemplate...until I got stucked in a *lil* complication.

We're trying to combine xAjax+mosTabs+patTemplate.

Our problem:
1. mosTabs (using patFactory) doesnt display 'tabbed' pages (it seems that it the necessary .css/.js files arent loaded/linked properly)
2. patTemplate cant load other templates.

Scenario:
We're building a component for online mgt (add,view,edit,delete) of research, experts and institutions database. We're attempting to follow a MCV design pattern.

Structure:
herdin.php - main component file
herdin.html.php - main component 'view' file
actions/*.php - (research,expert,institutions) 'action' files (acl checks, sql routines, etc)
views/*.html.php - (research,expert,institutions) 'view' file (form/page displaying functions, etc)
tmpl/*.html - images, template files
lib/* - third-party libraries (ajax, javascripts, etc)

We implemented this structure via switch statement in the main component file. Instead of common parameter $task, we used $type for the 'actions' (research, expert, institution) and $task for..well task (add, edit, etc) (i.e. http://localhost/joomla/index.php?optio ... h&task=add):

Code: Select all

<?php
/** ensure this file is being included by a parent file */
defined('_VALID_MOS') or die ('Direct Access to this location is not allowed.');

// include patTemplate file
require_once($mosConfig_absolute_path . '/includes/patTemplate/patTemplate.php');

// include xAjax file
require_once($mosConfig_absolute_path . '/components/com_herdin/lib/xajax/xajax.inc.php');
$xajax = new xajax();
//$xajax->cleanBufferOn();
$xajax->registerFunction("functionLoader");
$xajax->processRequests();
$xajax->printJavascript($mosConfig_live_site . '/components/com_herdin/lib/xajax/', 'xajax.js');

// include main herdin view class
require_once($mainframe->getPath('front_html'));

/** Select type */
	$type = mosGetParam( $_REQUEST, 'type', '');
	switch($type) {
	case 'research':
	  	// include research class files
		require_once($mosConfig_absolute_path.'/components/com_herdin/actions/research.php');
		require_once($mosConfig_absolute_path.'/components/com_herdin/views/research.html.php');
		
		ResearchAction::handleType();
		break;
	case 'expert':
		// include expert class files
		require_once($mosConfig_absolute_path.'/components/com_herdin/actions/expert.php');
		require_once($mosConfig_absolute_path.'/components/com_herdin/views/expert.html.php');
		
		ExpertAction::handleType();	
		break;
	case 'institution':
	  	// include expert class files
		require_once($mosConfig_absolute_path.'/components/com_herdin/actions/institution.php');
		require_once($mosConfig_absolute_path.'/components/com_herdin/views/institution.html.php');
		
		break;
	default:
	  	// Display Default Herdin page
		getHerdinPage();		
		break;
}

// default Herdin page generator
function getHerdinPage() {
	
	// call toolbar function
	$toolbar = "";
			
	// now call task-specific function
	$content = "DEFAULT HERDIN PAGE";
	
	// render our page
	HerdinScreens::createTemplate($toolbar, $content);

}

// ajax function loader
function functionLoader( $element, $property, $type, $task, $data="" ) {

	// Call appropriate task:type function
	global $mosConfig_absolute_path;
	
	//Herdin main
	$lookup['herdin']['action']		= '/components/com_herdin/herdin.php';
	$lookup['herdin']['html']		= '/components/com_herdin/herdin.html.php';
	
	$lookup['herdin']['toolbar'] 	= 'HerdinScreens::showToolbar($data);';
	
	//Research
	$lookup['research']['action']	= '/components/com_herdin/actions/research.php';
	$lookup['research']['html']		= '/components/com_herdin/views/research.html.php';
	
	$lookup['research']['add'] 		= 'ResearchAction::getForm($data);';
	$lookup['research']['view'] 	= 'ResearchAction::getDetails($data);';
	$lookup['research']['default'] 	= 'ResearchAction::getList();';
		
	//Experts
	$lookup['experts']['action']	= '/components/com_herdin/actions/experts.php';
	$lookup['experts']['html']		= '/components/com_herdin/views/research.html.php';	
		
	require_once($mosConfig_absolute_path . $lookup[$type]['action']);
	require_once($mosConfig_absolute_path . $lookup[$type]['html']);
			
	$newContent = eval('return ' . $lookup[$type][$task]);
			
    $objResponse = new xajaxResponse();
    $objResponse->addAssign( $element, $property, $newContent );
    return $objResponse->getXML();
}
?>
Now here's our problem:

Using mosToolbar, we have a xajax registered function call that will display the appropriate toolbar and form (tabbed form):

Code: Select all

onclick="xajax_functionLoader( 'herdinContent', 'innerHTML', 'research', 'add' );xajax_functionLoader( 'herdinToolbar', 'innerHTML', 'herdin', 'toolbar', 'addEdit' ); return false;"><img src="http://localhost/joomla/administrator/images/new_f2.png" alt="New" name="new" align="middle" border="0"><br>New</a></td>
The type=research, task=add parameter will call this function:

Code: Select all

	function getForm( $data="" ) {
		// check selected category
		$category = $data['researchCategory'];
		//$category = mosGetParam( $_REQUEST, 'researchCategory', '');
		
		// do some sql statement and conditions
		// call display function
		$form = ResearchView::showForm($category);
		return $form;
	}
...which in turn calls its 'view' counterpart function:

Code: Select all

function showForm($category) {
		global $mosConfig_absolute_path;
		$hasTabs = 0;
		// define appropriate html file based on passed category
		// setting books as default
		if ($category==2) {
			$htmlFile = 'researchThesisForm.html';
			$title = "Thesis";
		} elseif ($category==3) {
			$htmlFile = 'researchProjectsForm.html';
			$title = "Projects";
		} else {
			$hasTabs = 1;
			$htmlFile = 'researchBooksForm.html';
			$title = "Books";
		}
		
		$tmplfile= $mosConfig_absolute_path.'/components/com_herdin/tmpl/'.$htmlFile;
				
		// check if we has tabs
		if ($hasTabs) {
			$formTemplate =& patFactory::createTemplate( $option, true, false );
			//$formTemplate->dump();
			$formTemplate->setRoot($mosConfig_absolute_path.'/components/com_herdin/tmpl');
			$formTemplate->readTemplatesFromInput($htmlFile);
			$formTemplate->addVar('researchForm', 'tabletitle', "New Research Entry (Category:$title)");
			
			// workaround to fetch the required mostabs js and css
			ob_start();
			$tabs = new mosTabs(1); //unset($tabs);
			$tabsLib = ob_get_contents();
			ob_end_clean();
			
			$formTemplate->addVar('researchForm', 'tabslib', $tabsLib);
			//$formTemplate->addObject('researchForm', $tabs);	
		}
		else {
			// Table title
			$formTemplate =& new patTemplate();
			$formTemplate->readTemplatesFromFile($tmplfile);
			$formTemplate->addVar('researchForm', 'tabletitle', "New Research Entry (Category:$title)");
		}
		
		// Generate our category list. First define javascript behavior
		$onChange = "onChange=\"xajax_functionLoader( 'herdinContent', 'innerHTML', 'research', 'add', xajax.getFormValues('adminForm') );\"";
		$formTemplate->addVar('researchForm', 'selectcategory', ResearchView::createCategoryList($onChange, $category));
		$form = $formTemplate->getParsedTemplate('researchForm');
		return $form;
	}
here's the template that a call for patFactory uses:

Code: Select all

<mos:tmpl name="researchForm">
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td width="74%" height="45" align="left" valign="middle" nowrap="nowrap" class="herdinTableTitle">{TABLETITLE} </td>
        </tr>
    <tr>
        <td height="45" align="left" valign="middle" nowrap="nowrap">Change category: {SELECTCATEGORY}</td>
        </tr>
    <tr>
        <td height="45" align="left" valign="middle" nowrap="nowrap">
		<!-- Tabbed form starts here -->
		{TABSLIB}
		<mos:Call template="starttabpane" paneid="1" panecookies="0"/>
		<mos:Call template="starttab" paneid="1" tabtitle="Basic"/>
		
		<table width="96%"  border="0" align="center">
        <tr>
            <td> </td>
            <td>Tab1</td>
        </tr>
        <tr>
            <td width="13%">Title</td>
            <td width="87%"><input name="textfield" type="text" value="researchTitle" />
            </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
        </tr>
   		</table>
		
		<mos:Call template="endtab"/>
		<mos:Call template="starttab" paneid="1" tabtitle="Advance"/>
		
		<table width="96%"  border="0" align="center">
        <tr>
            <td> </td>
            <td>Tab2</td>
        </tr>
        <tr>
            <td width="13%">Title</td>
            <td width="87%"><input name="textfield" type="text" value="researchTitle" />
            </td>
        </tr>
        <tr>
            <td> </td>
            <td> </td>
        </tr>
    	</table>
		
		<mos:Call template="endtab"/>
		<mos:Call template="endtabpane"/>
		</td>
    </tr>
</table>
</mos:tmpl>
and here's the template file for our call for a new patTemplate object:

Code: Select all

<patTemplate:tmpl name="researchForm">
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td width="74%" height="45" align="left" valign="middle" nowrap="nowrap" class="herdinTableTitle">{TABLETITLE} </td>
        </tr>
    <tr>
        <td height="45" align="left" valign="middle" nowrap="nowrap">Change category: {SELECTCATEGORY}</td>
        </tr>
</table>
<table width="96%"  border="0" align="center">
    <tr>
        <td> </td>
        <td>TEMP: (Thesis )Research Form </td>
    </tr>
    <tr>
        <td width="13%">Title</td>
        <td width="87%">
            <input name="textfield" type="text" value="researchTitle" />
</td>
    </tr>
    <tr>
        <td> </td>
        <td> </td>
    </tr>
</table>
</patTemplate:tmpl>
I have no idea how to explain this in a simpler way. My apologies for such a long post. Help anyone?

SaVaTaGe
Joomla! Intern
Joomla! Intern
Posts: 75
Joined: Mon Jan 23, 2006 7:22 pm

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by SaVaTaGe » Sun Sep 03, 2006 7:23 am

I think this is the right topic for my question  :-[

I have been developing a multi-lang, pat based component, now coding the config part of it, I think it may be cool to use panes, and implement the pane code into pat template as described  above. There is no problem right there.

It works but as I said component is multi-lang so I have been using language file and importing its variables to pat template by:

Code: Select all

$tmpl->addGlobalVars( $lang );	
and using them like this :

Code: Select all

<table class="adminheading">
	<tr>
		<th class="icon-48-config">{CONFIG}</th>
		<td align="right" nowrap="true"> </td>
	</tr>
</table>
What if I want to connect tab-title to language?

Code: Select all

<mos:Call template="starttab" paneid="1" tabtitle="{CONF_IMAGE}"/>
Waiting you suggestions...

tHanks...

Alejo
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 220
Joined: Fri Aug 19, 2005 12:28 pm
Contact:

Re: HowTo: 1. mosTabs and 2. patTemplate in combination

Post by Alejo » Mon Sep 04, 2006 9:11 pm

How exactly did you get the tabs to work with patT?

The way I work with language translation is like this:

_LANG_CONSTANT but I am not sure if that will work in your case.
https://www.jreviews.com/joomla directory, classifieds, and reviews system for Joomla and WordPress


Locked

Return to “patTemplate”