nacitanie obsahu php

Programovacie jazyky, rady, poradňa...
mio001
Amateur
Amateur
Príspevky: 30
Registrovaný: 05 okt 2007, 8:18

nacitanie obsahu php

Príspevok od používateľa mio001 »

Dobry den,

prosim Vas akym prikazom mozem nacitat php do druheho suboru.

Vysvetlim:

Mam spraveny web a potrebujem do jedneho uz fungujuceho suboru vlozit este kod z druheho php suboru, ked som to len prekopiroval, nenacitalo mi to vsetko, asi chyba v cestach, preto by bolo jednoduchsie to tahat priamo z povodneho suboru, lebo je to robene v Joomla a v administracii ba bol zmatok.

Dakujem za pomoc.

E.
markus
Light Professional
Light Professional
Používateľov profilový obrázok
Príspevky: 950
Registrovaný: 24 feb 2005, 23:53

Re: nacitanie obsahu php

Príspevok od používateľa markus »

include ?
mio001
Amateur
Amateur
Príspevky: 30
Registrovaný: 05 okt 2007, 8:18

Re: nacitanie obsahu php

Príspevok od používateľa mio001 »

To som skusal ale nezobrazi mi vsetko.

dal som do povodneho php

Kód: Vybrať všetko

include('search.php');
je to vyhladavaci formular, popis zobrazi cely ale polozky na vyber nezobrazi. Kde moze byt chyba?

D.
BX
Addict
Addict
Používateľov profilový obrázok
Príspevky: 4572
Registrovaný: 10 jan 2008, 15:30

Re: nacitanie obsahu php

Príspevok od používateľa BX »

No niekde určite bude :P
Skús include bez zátvoriek (možno je to fuk, neviem) a keď nie, daj sem radšej väčší úsek kódu z pôvodného a celý ten search.
mio001
Amateur
Amateur
Príspevky: 30
Registrovaný: 05 okt 2007, 8:18

Re: nacitanie obsahu php

Príspevok od používateľa mio001 »

Toto je subor s vyhladavanim:

Kód: Vybrať všetko

<?php

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

global $Itemid;
$configx = $this->config;
$makemods = $this->makemods;
$lists = $this->lists;

$configx = $this->config;

$task = JRequest::getVar('task', '');

EZAutosHelper::EZHeader();



$link1 = JRoute::_( 'index.php?option=com_ezautos&controller=listings&task=results&Itemid='. $Itemid );


?>

<?php
if ( $configx->ea_usemakmod ) {
?>

    <script language="javascript" type="text/javascript">
    <!--

    var makemods = new Array;
    <?php
    $i = 0;
    foreach ($makemods as $k=>$items) {
    	foreach ($items as $v) {
    		echo "makemods[".$i++."] = new Array( '$k','".addslashes( $v->value )."','".addslashes( $v->text )."' );\n\t\t";
    	}
    }
    ?>

    //-->
    </script>
<?php
}
?>


<br/><br/>

<table width="90%" align="center" cellpadding="5"><tr><td>


<table width="100%" cellpadding="10" class="listtableborder"><tr><td>

<form name="adminForm" id="adminForm" action="<?php echo JRoute::_("index.php?");?>" method="get">
	<input type="hidden" name="option" value="com_ezautos" />
	<input type="hidden" name="controller" value="listings" />
	<input type="hidden" name="task" value="results" />
	<input type="hidden" name="Itemid" value="<?php echo $Itemid;?>" />
<?php if (!$configx->ea_usecat) { ?>
	<input type="hidden" name="cid" value="0" />
<?php }
if (!$configx->ea_usetype) { ?>
	<input type="hidden" name="type" value="0" />
<?php }
if (!$configx->ea_usemakmod) { ?>
	<input type="hidden" name="make" value="0" />
	<input type="hidden" name="model" value="0" />
<?php }
if (!$configx->ea_usetrans) { ?>
	<input type="hidden" name="trans" value="0" />
<?php }
if (!$configx->ea_useeng) { ?>
	<input type="hidden" name="engine" value="0" />
<?php }
if (!$configx->ea_usefuel) { ?>
	<input type="hidden" name="fuel" value="0" />
<?php }
if (!$configx->ea_usecond) { ?>
	<input type="hidden" name="tag" value="0" />
<?php }
if (!$configx->ea_usepcode) { ?>
	<input type="hidden" name="postcode" value="" />
	<input type="hidden" name="radius" value="" />
<?php }
if (!$configx->ea_usecolour) { ?>
	<input type="hidden" name="colour" value="0" />
<?php }
if (!$configx->ea_usedoors) { ?>
	<input type="hidden" name="doors" value="0" />
<?php }
if (!$configx->ea_usebody) { ?>
	<input type="hidden" name="body" value="0" />
<?php }
if (!$configx->ea_maxmiles) { ?>
	<input type="hidden" name="maxmiles" value="0" />
<?php }
if (!$configx->ea_useyear) { ?>
	<input type="hidden" name="minyear" value="0" />
	<input type="hidden" name="maxyear" value="0" />
<?php }
if ($configx->ea_sitetype!=0) { ?>
	<input type="hidden" name="minprice" value="" />
	<input type="hidden" name="maxprice" value="" />
<?php }
if (!$configx->ea_usekeyword) { ?>
	<input type="hidden" name="keyword" value="" />
<?php } ?>
	<input type="hidden" name="type" value="0" />


<table border="0" width="100%">
	<tr>
		<td class="h2"><?php echo JText::_('EZAUTOS_SEARCHADV');?><br /><br /></td>
	</tr>
	<tr>
		<td>

		<table border="0" cellspacing="2" cellpadding="5" class="formbkgr">
<?php if ($configx->ea_usetype) { ?>
	<tr>
		<td><?php echo JText::_('EZAUTOS_TRANSACTION_TYPE');?>:-</td>
		<td colspan="2"><?php echo $lists['type'];?></td>
	</tr>
<?php }
if ($configx->ea_usecond) { ?>
	<tr>
		<td><?php echo JText::_('EZAUTOS_VLDET_TAG');?>:-</td>
		<td colspan="2"><?php echo $lists['tag'];?></td>
	</tr>
<?php }
if ($configx->ea_usecat) { ?>
	<tr>
		<td><?php echo JText::_('EZAUTOS_SEARCHVEHTYPE');?>:-</td>
		<td colspan="2"><?php echo $lists['cid'];?></td>
	</tr>
<?php }
if ( $configx->ea_sitetype==0 ) { ?>
	<tr>
		<td width="130"><?php echo JText::_('EZAUTOS_SEARCHPRICE');?>:-</td>
		<td><?php echo $lists['minprice'];?></td>
		<td><?php echo $lists['maxprice'];?></td>
	</tr>
<?php }
if ($configx->ea_useyear) { ?>
	<tr>
		<td width="130"><?php echo JText::_('EZAUTOS_SEARCH_AGERANGE');?>:-</td>
		<td><?php echo $lists['minyear'];?></td>
		<td><?php echo $lists['maxyear'];?></td>
	</tr>

<?php }
if ($configx->ea_usemakmod) { ?>
	<tr>
		<td><?php echo JText::_('EZAUTOS_SEARCH_MAKE').' '. JText::_('EZAUTOS_SEARCH_MODEL');?>:-</td>
		<td><?php echo $lists['maid'];?></td>
		<td><?php echo $lists['moid'];?></td>
	</tr>
<?php }
if ($configx->ea_useeng) { ?>
	<tr>
		<td><?php echo JText::_('EZAUTOS_VLDET_ENG');?>:-</td>
		<td colspan="2"><?php echo $lists['engine'];?></td>
	</tr>
<?php }
if ($configx->ea_usetrans) { ?>
	<tr>
		<td><?php echo JText::_('EZAUTOS_DDSL_TRANS');?>:-</td>
		<td colspan="2"><?php echo $lists['trans'];?></td>
	</tr>
<?php }
if ($configx->ea_usefuel) { ?>
	<tr>
		<td><?php echo JText::_('EZAUTOS_VLDET_FUEL');?>:-</td>
		<td colspan="2"><?php echo $lists['fuel'];?></td>
	</tr>
<?php }
if ($configx->ea_usecolour) { ?>
	<tr>
		<td><?php echo JText::_('EZAUTOS_VLDET_COLOUR');?>:-</td>
		<td colspan="2"><?php echo $lists['colour'];?></td>
	</tr>
<?php }
if ($configx->ea_usedoors) { ?>
	<tr>
		<td><?php echo JText::_('EZAUTOS_SEARCH_DOORS');?>:-</td>
		<td colspan="2"><?php echo $lists['doors'];?></td>
	</tr>
<?php }
if ($configx->ea_usebody) { ?>
	<tr>
		<td><?php echo JText::_('EZAUTOS_SPECS_BODY');?>:-</td>
		<td colspan="2"><?php echo $lists['body'];?></td>
	</tr>
<?php }
if ($configx->ea_maxmiles) { ?>
	<tr>
		<td><?php echo JText::_('EZAUTOS_SCHMILES');?>:-</td>
		<td colspan="2"><input name="maxmiles" class="searchfield" maxlength="10" type="text" /></td>
	</tr>
<?php }
if ($configx->ea_usepcode){ ?>
	<tr>
		<td><?php echo JText::_('EZAUTOS_SEARCH_PCODEAREA');?>:-</td>
		<td colspan="2"><input name="postcode" class="slimfield" maxlength="6" type="text" /> <?php echo $lists['my_radius'];?></td>
	</tr>
<?php }
if ($configx->ea_usekeyword){ ?>
	<tr>
		<td><?php echo JText::_('Keyword');?>:-</td>
		<td colspan="2"><input name="keyword" class="searchfield" maxlength="10" type="text" /></td>
	</tr>
<?php } ?>


	<tr>
		<td><?php echo JText::_('EZAUTOS_SEARCH_SEARCHORD');?>:-</td>
		<td colspan="2"><select name="direction" class="searchbox"> 
		<option value="DEFAULT"><?php echo JText::_('EZAUTOS_DDSL_DEFAULT');?></option>
		<option value="ASCPRICE"><?php echo JText::_('EZAUTOS_DDSL_PRASC');?></option>
		<option value="DESCPRICE"><?php echo JText::_('EZAUTOS_DDSL_PRDESC');?></option>
		<option value="ASCID"><?php echo JText::_('EZAUTOS_DDSL_IDASC');?></option>
		<option value="DESCID"><?php echo JText::_('EZAUTOS_DDSL_IDDESC');?></option>
		</select></td>
	</tr>
	<tr>
		<td></td>
		<td colspan="2"><input class="button" type="submit" name="submit" value="<?php echo JText::_('EZAUTOS_INCLUDES_SEARCH');?>" /></td>
	</tr>
</table>

	</td>
	</tr>
	</table>
	</form>

</td></tr></table>

<br /><br /><br />

</td></tr></table>
Tuto potrebujem vlozit formlular vyssie popisany:

Kód: Vybrať všetko

<?php



// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

[b]include('components/com_ezautos/views/listings/tmpl/search.php');[/b]

global $Itemid;

EZAutosHelper::EZHeader();

$user =& JFactory::getUser();
$configx = $this->config;
$category = $this->category;
$rows = $this->rows;
$pageNav = $this->pageNav;

if (!$configx->ea_colcount){
	$colcount 	= "4";
} else {
	$colcount 	= $configx->ea_colcount;
}
if (!$configx->ea_colwidth){
	$colwidth 	= "25%";
} elseif ($configx->ea_colwidth && !$configx->ea_colcount){
	$colwidth 	= "25%";
} else {
	$colwidth 	= $configx->ea_colwidth;
}

if ($configx->ea_listtemplate) {
	define("TEMPLATE_PATH","components/com_ezautos/forms/list_templates/".$configx->ea_listtemplate);
} else {
	define("TEMPLATE_PATH","components/com_ezautos/forms/list_templates/template2");
}

?>

<br />
<table width="100%" border="0" cellspacing="1" cellpadding="4">
	<tr>
		<td class="sectiontableheader"><?php echo stripslashes($category->name);?></td>
	</tr>
</table>

<?php

$num_rows=ceil( count( $rows ) / 1 );
if ($num_rows > 0) {

	if ($configx->ea_listtemplate == 'multicolumn') {


		echo "<table border='0' width='100%'>";
		echo "<tr>";

		$rowcounter = 0;
		foreach($rows as $row) {

		$number = $row->price;

		if ($configx->ea_currencyformat==0) {

			$formatted_price = number_format($number);
		} else {
			$formatted_price = number_format($number, 2,",",".");
		}


			if (($rowcounter%$colcount==0) AND ($rowcounter<>0)) echo "</tr><tr>";


			if (file_exists(TEMPLATE_PATH.'/listshort.ezautos.php')) {
				include(TEMPLATE_PATH.'/listshort.ezautos.php');
			} else {
				echo JText::_('EZAUTOS_TEMPLATE_ERROR');
			}

			$rowcounter++;
		}
		if ($rowcounter%$colcount<>0) {
			for ($i = 1; $i <= ($colcount-($rowcounter%$colcount)); $i++) {
				echo "<td width='$colwidth' valign='top'> </td>";
			}
		}
		echo "</tr></table>";

	} else {

		$k = 0;
		for ($i=0, $n=count( $rows ); $i < $n; $i++) {
			$row = &$rows[$i];

			$number = $row->price;

		if ($configx->ea_currencyformat==0) {

			$formatted_price = number_format($number);
		} else {
			$formatted_price = number_format($number, 2,",",".");
		}


			if (file_exists(TEMPLATE_PATH.'/listshort.ezautos.php')) {
				include(TEMPLATE_PATH.'/listshort.ezautos.php');
			} else {
				echo JText::_('EZAUTOS_TEMPLATE_ERROR');
			}


		}

	}

}else{

?>

<table width='100%' border='0' cellspacing='1' cellpadding='0'>
	<tr>
		<td class='h3'><br /><br /><?php echo JText::_('EZAUTOS_NOCATLISTINGS');?><br /><br /><br /></td>
	</tr>
</table>
			<table border="0" cellpadding="0" cellspacing="0" width="100%" class="sectiontableheader">
				<tr>
					<td><img src="<?php echo JURI::root();?>components/com_ezautos/images/pixel.gif" border="0" height="2" width="1" alt="" /></td>
				</tr>
			</table>

<?php

}

?>
<?php
$link = JRoute::_( 'index.php?option=com_ezautos&controller=categories&task=view&Itemid='. $Itemid );
?>

<form name="pageForm" action="<?php $link;?>" method="get">
<input type="hidden" name="option" value="<?php echo $option;?>" />
<input type="hidden" name="controller" value="categories" />
<input type="hidden" name="task" value="<?php echo $_REQUEST['task'];?>" />
<input type="hidden" name="id" value="<?php echo $_REQUEST['id'];?>" />
<input type="hidden" name="Itemid" value="<?php echo $Itemid;?>" />


<table width='100%' border='0' cellspacing='1' cellpadding='0'>
    <tr>
        <td colspan="2"><div align="center"><?php echo $pageNav->writeLinks($link); ?></div></td>
    </tr>
    <tr>
        <td><?php echo $pageNav->writeCounter();?></td><td><div align="right"><?php echo JText::_('EZAUTOS_LISTINGS_DISPLAYNUM');?> <?php echo $pageNav->getBox($link);?></div></td>
    </tr>
</table>

</form>
Ten tucny kod som tam vlozil, skusal som aj bez zatvoriek, zial nepomohlo. ( include('components/com_ezautos/views/listings/tmpl/search.php'); )

Dakujem.
Napísať odpoveď