multiple components in one page.

For Joomla! 1.0 Coding related discussions.
Locked
User avatar
sinanata
Joomla! Intern
Joomla! Intern
Posts: 84
Joined: Thu Aug 18, 2005 9:36 pm
Location: Turkey/Istanbul
Contact:

multiple components in one page.

Post by sinanata » Sun Feb 05, 2006 11:27 pm

hi there.

I'm looking for a bot system like...

Code: Select all

<div id="asd">
{com_content}

</div>

<div id="asd1">

{com_contacts}
</div>

<div id="asd2">
{com_joomlaboard}

</div>
I'll prepare a big interface like this in html and I want to get the data of all components in index page.How can I do this please help me.
Last edited by sinanata on Sun Feb 05, 2006 11:30 pm, edited 1 time in total.

User avatar
Manoxtra
Joomla! Intern
Joomla! Intern
Posts: 62
Joined: Thu Aug 18, 2005 5:35 pm
Location: Holland
Contact:

Re: multiple components in one page.

Post by Manoxtra » Mon Feb 06, 2006 9:07 am

I would like to know this too..  :)
Power to the devs!!!

besnik
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Mon Feb 06, 2006 9:45 am

Re: multiple components in one page.

Post by besnik » Mon Feb 06, 2006 9:55 am

Mabe an idea :

Create a new component which includes other components, like :

Code: Select all

$task = "show"; // Define the task for the component 
include("./components/com_content/content.php");

$task = "list";
include("./components/com_joomlaboard/joomlaboard.php");
Thought, it could be a good idea to make a generic component allowing to include other components. It can be useful as a home page !!!

User avatar
pisdoktor
Joomla! Explorer
Joomla! Explorer
Posts: 349
Joined: Fri Aug 19, 2005 8:41 am
Location: Denizli -Türkiye | C* |
Contact:

Re: multiple components in one page.

Post by pisdoktor » Mon Feb 06, 2006 1:59 pm

but this codes don't work...
Last edited by pisdoktor on Sun Feb 12, 2006 6:01 pm, edited 1 time in total.
http://www.sonerekici.com - Personel Web Site

friesengeist
Joomla! Guru
Joomla! Guru
Posts: 842
Joined: Sat Sep 10, 2005 10:31 pm

Re: multiple components in one page.

Post by friesengeist » Sun Feb 12, 2006 12:09 pm

Many components use mosGetParam(), so

Code: Select all

$_REQUEST['task'] = "whateverthetaskis";
might be better than
besnik wrote:

Code: Select all

$task = "show"; // Define the task for the component 
[...]
There is also a function mosLoadComponent() in includes/frontend.php that does exactly the include() besnik is talking about. Don't know if it works, though, have never used it ;-)
We may not be able to control the wind, but we can always adjust our sails

vreemt
Joomla! Apprentice
Joomla! Apprentice
Posts: 22
Joined: Sun Apr 02, 2006 1:07 am
Contact:

Re: multiple components in one page.

Post by vreemt » Mon May 01, 2006 11:40 am

i am developing a similar thing that works as a component
so far i;ve been able to include body text from actual components by adding tags to the front end (template file)

the tags (html comments, start and end) are mainly to identify mosMainBody();
the function i use reads in the component via hte front end (index.php?option=com_something) into a string, sorts out the bit in between
the tags and ideally replaces the links in the component itself so instead of index.php?option=com_something it will link to index.php?option=com_mycomponent&loadcomponent=com_something, including all params passed to the original link.

i seem to be a bit stuck on passing the parameters, but i should be able to figure this out soon.

anyone interested can try the link to Virtual Office http://joomla.spacetubbie.nl (i'm still testing!)
or let me know and i'll post some code

comments or ideas would be appreciated!!

User avatar
mjaz
Joomla! Guru
Joomla! Guru
Posts: 821
Joined: Thu Nov 10, 2005 10:08 am
Contact:

Re: multiple components in one page.

Post by mjaz » Tue May 02, 2006 7:28 pm

vreemt wrote: the tags (html comments, start and end) are mainly to identify mosMainBody();
the function i use reads in the component via hte front end (index.php?option=com_something) into a string, sorts out the bit in between
the tags and ideally replaces the links in the component itself so instead of index.php?option=com_something it will link to index.php?option=com_mycomponent&loadcomponent=com_something, including all params passed to the original link.
If I understand correctly what you're doing, then you could probably make it simpler using this syntax:
yoursite.com/index2.php?option=component&no_html=1

When using index2.php instead of index.php, you only get the and the component's output, without modules or the template. If you use nohtml=1 (in the url or in $_POST) you only get the raw component output, without any other html.
Better SEO & multi-lingual Joomla sites with Nooku Content
http://www.nooku.org
Nooku Framework for advanced Joomla extension development
http://www.nooku.org/framework

vreemt
Joomla! Apprentice
Joomla! Apprentice
Posts: 22
Joined: Sun Apr 02, 2006 1:07 am
Contact:

Re: multiple components in one page.

Post by vreemt » Thu May 04, 2006 10:10 pm

works pretty good, had to remember to put a form action, as without that it creates a link without all the options as the querystring.
working example at http://joomla.spacetubbie.nl/index.php? ... virtoffice
needs some styling as it would look nicer with the form elements horizontal

my virtual office project currently is a changed project, i'm going to try n accomplish the same with a template and complicated menu-structure (components added to certain menu;s, with their options displaying on the corresponding pages and in various module positions)

vreemt
Joomla! Apprentice
Joomla! Apprentice
Posts: 22
Joined: Sun Apr 02, 2006 1:07 am
Contact:

Re: multiple components in one page.

Post by vreemt » Fri Apr 06, 2007 8:48 pm

to rewrite the urls from various components and make sure virtoffice kept its own links in place, i encoded the parameters passed between other components. This was done using urlencode() and urldecode(). Hotmail uses the same sort of method to pass parameters, but some servers/sites aren;t set up to handle them properly. The encoding turns &, ? and other symbols into equivalent %-codes.

The displayed output from a component is loaded via index2.php?no_html=1

i;ve used the following things in my component.php file:

-Declaration of variables

Code: Select all

$voTask = ""; //component reference: com_zoom, com_contact etc
$voPag = "";  //identifier for display purposes
$voParams = ""; $voTempParams = ""; //parameter storage
$pagInfo = ""; //url for the component page to load

$voTask = mosGetParam($_POST,"voTask","start");
$voPag = mosGetParam($_POST,"voPag","");
$voParams = mosGetParam($_POST,"voParams","");//submit: elements encoded, read: elements decoded
-Set/Get parameters
(the address/url for the component page it needs to load is stored in $pagInfo, see below)

Code: Select all

if ( ($voPag == "") || ($voParams == "") ) {
	$voTask = mosGetParam($_REQUEST,"votask","start");
	$voPag = mosGetParam($_REQUEST,"vopag","");
	$voTempParams = mosGetParam($_REQUEST,"votparams","");
}
if ( ($voParams == "") && ($voTempParams != "") ) {
	$voParams = urldecode($voTempParams);
}	

$voPath = $mosConfig_live_site;

if ($voTask != "start") {	
	$pagInfo = $voPath."/index2.php?no_html=1&option=".$voTask.$voParams; 
}

$voComPath = $voPath."/components/com_skvirtoffice";
-Link to contact form

Code: Select all

<?php /* encode params: */		$contactp = urlencode("&task=view&contact_id=2&Itemid=43"); ?>
		<li><a href="index.php?option=com_skvirtoffice&votask=com_contact&votparams=<?php echo $contactp; ?>">contact test</a></li>
-Button for contact form with fields that are automatically encoded

Code: Select all

<form action="index.php?option=com_skvirtoffice" method="post"><input type="hidden" name="voTask" value="com_contact"><input type="hidden" name="voParams" value="&task=view&contact_id=2&Itemid=43"><input type="submit" name="voPag" value="contact"></form>
-Encoding links on component page

Code: Select all

		<div class="sk_vo_pag" id="<?php echo $voPag; ?>">				
<?php	
	if ($pagInfo != "") { 

		$scanresult = ""; $displayCompContents = "";

		$scanresult = file_get_contents($pagInfo); 

		//READ STRING AND REPLACE LINKS
		if ($scanresult != "") {		//Content of a component 
			//step1 find links
			$displayCompContents = $scanresult;	//temp 
				//PHP FUNCTIONS:
				//strpos(haystack,needle,startpoint) & substr (string, startpoint, length) & str_replace(find,replace,string)

			$voP1 = "/index.php?option=com_";	$voP2 = "&";	$voP3 = "\"";
			$voReplaceLink = "/index.php?votask=com_";//+getlink
			$voReplaceParams = "&option=com_skvirtoffice&votparams=";//+urlencode($params);

			$voLen = strlen($displayCompContents); 
			$voP1Len = strlen($voP1); $voP2Len = strlen($voP2);
			
			$startPos = 0;
			for ($voPos = 1; $voPos < $voLen; $voPos + $startPos ) { //check whole string 
				//get pos $voP1, get pos $voP2, get a substring based on these positions:
					$startPos = strpos($displayCompContents, $voP1, $voPos + $voP1Len);
					if ($startPos === false) { break; }  //exit loop cos all occurances found
					
					$paramPos = strpos($displayCompContents, $voP2, $startPos + $voP1Len); //start from last char voP1
					$endPos = strpos($displayCompContents, $voP3, $paramPos + $voP2Len); //start from last char voP2
					//only get the bit inbetween $param and after $voP1, this is what defines the component name
					$voGetLink = substr ($displayCompContents, $startPos + $voP1Len, $paramPos - ($startPos+$voP1Len));
					$voGetParams = substr ($displayCompContents, $paramPos, $endPos - $paramPos);
					
			//step2 reset the links 
					//use the substrings and predefined link-bits to create the find- & replace with to use with str_replace()
					$voNewLink = $voReplaceLink.$voGetLink;
					$voNewParams = $voReplaceParams.urlencode($voGetParams).$voP3;
				
				$checklink = $voP1.$voGetLink.$voGetParams.$voP3;
				$replacelink = $voNewLink.$voNewParams;
				
				//mixed str_replace ( mixed needle, mixed str, mixed haystack )
					$displayCompContents = str_replace($checklink, $replacelink, $displayCompContents);
						
				$voLen = strlen($displayCompContents); 	//reset strlen of $display:
			}
			//step 1/2B - reset form options
				$checkform = "<input type=\"hidden\" name=\"option\" value=\"com_";
				$replaceform = "<input type=\"hidden\" name=\"option\" value=\"com_skvirtoffice\" />\n";
				$replaceform .= "<input type=\"hidden\" name=\"voTask\" value=\"com_".$voGetLink."";
				
					$displayCompContents = str_replace($checkform, $replaceform, $displayCompContents);

			//step3 print new content
			echo $displayCompContents;

		} else {
?>			<p>not found</p>
<?php	}	
			echo "<!-- ".$pagInfo." --> \n";
	}	else {
	
?>			<!-- empty!! -->
			<p>start</p> 
			
<?php	
	}


?>		<!-- end load pag -->
		</div>

quiquedcode
Joomla! Ace
Joomla! Ace
Posts: 1384
Joined: Thu Aug 18, 2005 10:11 pm
Location: San Juan - Argentina
Contact:

Re: multiple components in one page.

Post by quiquedcode » Wed Apr 18, 2007 9:41 pm

Hi guys
Sorry for bumping this thread, but I found it very interesting while researching about a job I gotta do

I have to display acajoom and a faclieforms's form in the same page

What would happen if I just put an include like this

Code: Select all

include("index2.php?option=facileforms&formid=2")
in the acajoom.html.php file ?

EDIT: tried doing the include, but everything showed very bad (nor 2nd component didn't show). Seems not an easy task to accomplish

Thanks a lot for helping and hope someday this feature is included in the next versions of joomla, as this is very useful sometimes.

Henry
Last edited by quiquedcode on Thu Apr 19, 2007 5:48 pm, edited 1 time in total.
@kabeza
Freelance Joomla/CodeIgniter Developer
Home: http://www.beza.com.ar

User avatar
verticalgrain
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 105
Joined: Mon Dec 01, 2008 4:16 am
Contact:

Re: multiple components in one page.

Post by verticalgrain » Tue Dec 14, 2010 11:30 pm

To revive this three year old thread to add another solution to this problem, you can use the "Include component" plugin to load a component in an article, and then maybe use the category blog layout to display multiple articles at once:

http://extensions.joomla.org/extensions ... clude/8741


Locked

Return to “Joomla! 1.0 Coding”