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>
Code: Select all
<div id="asd">
{com_content}
</div>
<div id="asd1">
{com_contacts}
</div>
<div id="asd2">
{com_joomlaboard}
</div>
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");
Code: Select all
$_REQUEST['task'] = "whateverthetaskis";
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 ;-)besnik wrote:Code: Select all
$task = "show"; // Define the task for the component [...]
If I understand correctly what you're doing, then you could probably make it simpler using this syntax: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.
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
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";
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>
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>
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>
Code: Select all
include("index2.php?option=facileforms&formid=2")