Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 12

Discussione: template

  1. #1
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    4,826

    template

    ho un template e devo inserire del codice php all' interno di questo ,come posso fare?
    codice:
    	<td align=center>proprietà
    	
    		
    --------><?php stampaDivMenu({id})}?> ----->non va
    
    </td>
    		<td align=center>stile</td>{lower}</td>
    		<td align=right>{upper}</td>
    		<td align=right>{childs}</td>
    		<td align=right>{root_id}</td>
    		<td align=right>{id}</td>
    		<td align=right>{lft}</td>
    		<td align=right>{rgt}</td>

  2. #2
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    4,826
    è un template della Pear , ma non ho capito a fondo come funziona fino alla registrazione delle variabili , ci sono , ma per richiamare una funzione non riesco a capire come si fa!!

  3. #3

    flexy template??

    Assunto che stai usando flexy il modo piu semplice per far
    richiamare una funzione é dichiararla come metodo della classe
    di output.
    Puoi invece richiamare direttamente una funzione aprendo i tag php ma dopo avere settato true l'opzione "allowPHP".

  4. #4
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    4,826
    mi puoi dire come si fa a dichiarare una funzione e come settare allowphp?
    scusa ma è la prima volta che lo uso

  5. #5
    Ma stai usando flexy o qualche altro template engine?!?!?

    Cmq sul manuale di Flexy e spiegato tutto.
    http://pear.php.net/manual/en/packag...figuration.php
    d[^_^]b ° y0u][|-|Zu
    http://www.webzone.it

  6. #6
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    4,826
    Ti ringrazio,ma non riesco a capire come settare le opzioni,e soprattutto come dichiarare la funzione.

    non so se è flexy,ti posto il codice:
    codice:
    $cfg['db']['dsn'] = 'mysql://root:1231977@localhost/nestedset';
    
    
    /**
     * Set template path
     */
    
    $cfg['tpl']['path'] = 'tpl/';
    
    
    /**
     * here wo go
     */
    
    
    $tpl = new Template_PHPLIB($cfg['tpl']['path']);
    
    $tpl->setFile(
    	array(
    		"page" => "TreeManager.tpl"
    	)
    );
    
    $tree = new NestedSet;
    $tree->connect($cfg['db']['dsn']);
    
    
    /**
     * manipulating the tree
     */
    
    $tpl->setBlock("page","explain","ph_explain");
    $tpl->setBlock("explain","explain_row","ph_explain_row");
    
    if ($_REQUEST["cmd"]=="node_new") {
    
    	// inserting a node
    
    	$node=(int)$_REQUEST["node"];
    
    	$tpl->setVar('code', '$new_id = $tree->nodeNew('.$node.');');
    	$tpl->parse("ph_explain_row","explain_row",true);
    
    	$new_id = $tree->nodeNew($node);
    
    	if (!$tree->isError($new_id)) {
    
    		$tpl->setVar('code', "// New node inserted: ".$new_id);
    		$tpl->parse("ph_explain_row","explain_row",true);
    
    		$tree->setNode($new_id, array("name"=>$_REQUEST["name"]));
    
    		$tpl->setVar('code', '$tree->setNode($new_id,array("name"=>"'.$_REQUEST["name"].'"));');
    		$tpl->parse("ph_explain_row","explain_row",true);
    
    	} else {
    
    		$tpl->setVar('code', "Error: ".$new_id->getMessage());
    		$tpl->parse("ph_explain_row","explain_row",true);
    
    	}
    
    	$tpl->parse("ph_explain","explain",true);
    
    } elseif ($_REQUEST["cmd"]=="node_del") {
    
    	// deleting a node
    
    	$node=(int)$_REQUEST["node"];
    
    	if ($_REQUEST["del_childs"]=="yes") {
    
    		$tpl->setVar('code', '$tree->nodeDel('.$node.',TRUE);');
    		$tpl->parse("ph_explain_row","explain_row",true);
    
    		$res = $tree->nodeDel($node,TRUE);
    
    		if (!$tree->isError($res)) {
    
    			$tpl->setVar('code', "Node deleted (incl. Childs): ".$node);
    			$tpl->parse("ph_explain_row","explain_row",true);
    
    		} else {
    
    			$tpl->setVar('code', "Error: ".$res->getMessage());
    			$tpl->parse("ph_explain_row","explain_row",true);
    
    		}
    
    	} else {
    
    		$tpl->setVar('code', '$tree->nodeDel('.$node.');');
    		$tpl->parse("ph_explain_row","explain_row",true);
    
    		$res = $tree->nodeDel($_REQUEST["node"]);
    
    		if (!$tree->isError($res)) {
    
    			$tpl->setVar('code', "Node deleted: ".$node);
    			$tpl->parse("ph_explain_row","explain_row",true);
    
    		} else {
    
    			$tpl->setVar('code', "Error: ".$res->getMessage());
    			$tpl->parse("ph_explain_row","explain_row",true);
    
    		}
    	}
    
    	$tpl->parse("ph_explain","explain",true);
    
    
    } elseif ($_REQUEST["cmd"]=="node_move") {
    
    	// moving a node (and its childs)
    
    	$node=(int)$_REQUEST["node"];
    
    	$tpl->setVar('code', '$tree->nodeMove('.$node.',"up");');
    	$tpl->parse("ph_explain_row","explain_row",true);
    
    	$res = $tree->nodeMove($_REQUEST["node"],"up");
    
    	if (!$tree->isError($res)) {
    
    		$tpl->setVar('code', "Node moved: ".$node);
    		$tpl->parse("ph_explain_row","explain_row",true);
    
    	} else {
    
    		$tpl->setVar('code', "Error: ".$res->getMessage());
    		$tpl->parse("ph_explain_row","explain_row",true);
    
    	}
    
    	$tpl->parse("ph_explain","explain",true);
    
    }
    
    
    /**
     * read tree from database
     */
    
    $treeItems = $tree->getNodes();
    
    
    /**
     * building forms for inserting an deleting nodes
     */
    
    $tpl->setBlock("page","form","ph_form");
    $tpl->setBlock("form","node_list","ph_node_list1");
    
    $tpl->setBlock("form","form_del","ph_form_del");
    
    $tpl->setVar('action', $_SERVER["PHP_SELF"]);
    
    if (is_array($treeItems) && count($treeItems)) {
    	foreach($treeItems AS $item) {
    		$indent="";
    		for($i=0;$i<$item["level"];$i++) {
    			$indent.="";
    		}
    		$tpl->setVar('id', $item["id"]);
    		$tpl->setVar('name', $indent.$item["name"]);
    		//$tpl->setBlock('page',stampaDivMenu(0),'stampa');
    
    		$tpl->parse("ph_node_list1","node_list",TRUE);
    		$tpl->parse("ph_node_list2","node_list",TRUE);
    	}
    
    	$tpl->parse("ph_form_del","form_del");
    }
    $tpl->parse("ph_form","form");
    
    
    /**
     * building table
     */
    
    $tpl->setBlock("page","table","ph_table");
    
    $tpl->setBlock("table","table_row","ph_table_row");
    
    $tpl->setBlock("table_row","struct","ph_struct");
    $tpl->setBlock("struct","struct_l","ph_struct_l");
    $tpl->setBlock("struct","struct_e","ph_struct_e");
    $tpl->setBlock("struct","struct_b","ph_struct_b");
    $tpl->setBlock("struct","struct_nb","ph_struct_nb");
    
    $tpl->setBlock("table_row","delete","ph_delete");
    $tpl->setBlock("delete","del_single","ph_del_single");
    $tpl->setBlock("delete","del_childs","ph_del_childs");
    
    $tpl->setBlock("table_row","move","ph_move");
    $tpl->setBlock("move","move_up","ph_move_up");
    $tpl->setBlock("move","move_not","ph_move_not");
    
    if (is_array($treeItems)) {
    
    	foreach($treeItems AS $key=>$item) {
    
    		if ($key%2) {
    			$tpl->setVar("col","#EEEEEE");
    		} else {
    			$tpl->setVar("col","#FFFFFF");
    		}
    
    		$tpl->setVar($item);
    
    		// Build the structure
    		$tpl->parse("ph_struct","");
    
    		if (($item["level"] == 1))
    			$parent = array();
    
    		if ( ($item["level"] >= $last["level"]))
    			$parent[$last["level"]] = $last;
    
    		for ($i=2;$i<$item["level"];$i++) {
    			if ($parent[$i]["lower"]) {
    				$tpl->parse("ph_struct","struct_l",true);
    			} else {
    				$tpl->parse("ph_struct","struct_e",true);
    			}
    		}
    
    		if ( ($item["level"] > 1) )
    			if ($item["lower"]) {
    				$tpl->parse("ph_struct","struct_b",true);
    			} else {
    				$tpl->parse("ph_struct","struct_nb",true);
    			}
    
    		// to move or not to move
    		$tpl->parse("ph_move","");
    		if ( $item["upper"] ) {
    			$tpl->parse("ph_move","move_up");
    		} else {
    			$tpl->parse("ph_move","move_not");
    		}
    
    		// childs ?
    		$tpl->parse("ph_delete","");
    		if ($item["childs"]) {
    			$tpl->parse("ph_delete","del_childs");
    		} else {
    			$tpl->parse("ph_delete","del_single");
    		}
    
    		$tpl->parse("ph_table_row","table_row",true);
    
    		$last=$item;
    
    	}
    	$tpl->parse("ph_table","table",true);
    
    }
    $tpl->pparse("out","page",true);
    $cfg['db']['dsn'] = 'mysql://root:Pixel1977@localhost/nestedset';
    $tree1 = new NestedSet;
    $tree1->connect($cfg['db']['dsn']);
    e il template:



    codice:
    <html>
    <head>
    <title>Gestione Pagine</title>
    <style type="text/css">
    <!--
    body,p,td {
    	font-size:12px;
    	font-weight:normal;
    	font-family:Helvetica,Arial;
    }
    -->
    
    </style>
    </head>
    <body bgcolor="#FFFFFF">
    
    
    
    
    
    	
    
    	
    
    
    
    
    	<hr noshade size=1 color="#000000">
    	<form action="{action}" method="get">
    	Inserisci nuovo nodo
    
    	<input type="hidden" name="cmd" value="node_new">
    	<input type="text" name="name"> 
    	come figlio di
    	<select name="node">
    		<option value="0">ROOT</option>
    		
    		<option value="{id}">{name}</option>
    		
    	</select>
    	<input type="submit" value="inserisci">
    	</form>
    	
    	
    	<form action="{action}" method="get">
    	Cancella nodo
    
    	<input type="hidden" name="cmd" value="node_del">
    	<select name="node">
    		{ph_node_list2}
    	</select>
    	<input type="checkbox" name="del_childs" value="yes"> incl. figli
    	<input type="submit" value="cancella">
    	<form>
    	
    
    
    
    	<hr noshade size=1 color="#000000">
    	
    
    	
    	<table cellpadding=0 cellspacing=0 border=0>
    	<tr bgcolor='#CCCCCC'>
    		<td>Name</td>
    		<td></td>
    		<td align=center width=100>Proprietà</td>
    	<!--	<td align=right width=80>Scegli stile</td>
    	<!--	<td align=right width=40>Upper</td>
    		<td align=right width=40>Childs</td>
    		<td align=right width=40>root</td>
    		<td align=right width=40>id</td>
    		<td align=right width=40>lft</td>
    		<td align=right width=40>rgt</td>
    	-->
    		</tr>
    	
    	
    	<tr bgcolor='{col}'>
    		<td bgcolor="#FFFFFF">
    			<table cellpadding=0 cellspacing=0 border=0>
    			<tr>
    				
    
    					
    						<td>[img]img/l.gif[/img]</td>
    					
    
    					
    						<td>[img]img/e.gif[/img]</td>
    					
    
    					
    						<td>[img]img/b.gif[/img]</td>
    					
    
    					
    						<td>[img]img/nb.gif[/img]</td>
    					
    
    				
    				<td>[img]img/f.gif[/img]</td>
    				<td>[img]img/e.gif[/img]</td>
    				<td>{name}</td>
    				<td>[img]img/e.gif[/img]</td>
    			</tr>
    			</table>
    		</td>
    		<td bgcolor='#CCCCCC'>
    			
    				
    				[img]img/up.gif[/img]
    				
    
    				
    				[img]img/e.gif[/img]
    				
    			
    
    			
    				
    				[img]img/del.gif[/img]
    				
    
    				
    				[img]img/delch.gif[/img]
    				
    			
    		</td>		
    		<td align=center>proprietà
    		
    <!--		<td align=center>stile</td><!--{lower}</td>
    <!--		<td align=right>{upper}</td>
    		<td align=right>{childs}</td>
    		<td align=right>{root_id}</td>
    		<td align=right>{id}</td>
    		<td align=right>{lft}</td>
    		<td align=right>{rgt}</td>	
    -->
    	</tr>
    	
     	</table>
    
    
    
    </body>
    </html>

  7. #7
    conosco questo template e il mio consiglio é di cambiarlo, é troppo noioso e complicato da usare, in oltre sostituisce le occorrenze e none un compilato come questi!!.

    Ce ne sono di diversi ma devi studiarteli prima.
    o Flexy (Classe PEAR)
    o Smarty (Classe PHP)

    Io preferisco Flexy!!
    d[^_^]b ° y0u][|-|Zu
    http://www.webzone.it

  8. #8
    Utente di HTML.it
    Registrato dal
    Jun 2003
    Messaggi
    4,826
    il problema è che lo devo usare per forza, il mio capo vuole che parta da li ,adesso mi informo bene sul template flexy per il futuro.
    Per il presente devo aggiungere solo quella dannata funzione al template sai dirmi come fare?
    altrimenti un link che non sono riuscito a trovare.
    Grazie mille per l'interesamento.

  9. #9
    conosci "saibal news 2.0"??

    ti consiglio di studiarti il sistema che viene utilizzato li per i template, è il migliore che abbia mai visto!

    Ciao!

  10. #10
    Originariamente inviato da giuseppe500
    il problema è che lo devo usare per forza, il mio capo vuole che parta da li ,adesso mi informo bene sul template flexy per il futuro.
    Per il presente devo aggiungere solo quella dannata funzione al template sai dirmi come fare?
    altrimenti un link che non sono riuscito a trovare.
    Grazie mille per l'interesamento.
    prova cosi:

    $str = tuaFunzione(..);
    $tpl->setVar('wildcards', $str);
    d[^_^]b ° y0u][|-|Zu
    http://www.webzone.it

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.