andrisp Posted July 14, 2005 Report Share Posted July 14, 2005 kaa buutu labaak un efektiigaak ? 1. Izmantot vienu index.php failu ar headeriem un footeriem, kur izmantojot require tiek inkludeetas satura lapas.. linki tad izskatiitos kaa index.php?cat=blabla vai 2. Katraa satura lapaa ievietot require("header.php") augshaa un require("footer.php") apakshaa ? vai 3. Pats izfunktiereeju - uztaisu mysql tabulu, kur ir divas kolomnas, viena ar unikaalu id, otra ar lapas faila nosaukumu. Tad pilniigi visi linki izskatiitos shaadaa stilaa index.php?cat=21.. index.php no datubaazes panjemtu attieciigo faila nosaukumu un inkludeetu.. kaadi veel varianti ? varbuut varat iedot linku, kur buutu skaisti aprakstiitas shaadas lietas ? Link to comment Share on other sites More sharing options...
bubu Posted July 14, 2005 Report Share Posted July 14, 2005 3 - nē (ja vien tikai netaisi kautkādu admin daļu, kurā tās lapas rediģēt) 1,2 - jā (es laikam par 1. variantu, ja īpaši nepatīk tā urļa sintakse, vienmēr var mod_rewrite pielietot) Link to comment Share on other sites More sharing options...
andrisp Posted July 14, 2005 Author Report Share Posted July 14, 2005 vispaar liidz shim arii esmu izmantojis pirmo metodi, bet liidz shim arii to inkludeejamo failu daudzums nav bijis paaraak liels un es izmantoju shaadu metodi if ($cat == 'tiri') { require("tiri.php"); } if ($cat == 'tiri1') { require("tiri1.php"); } if ($cat == 'tiri2') { require("tiri2.php"); } if ($cat == 'tiri3') { require("tiri3.php"); } bet ja to ir daudz, tad vairs nav tik eerti.. kaa dariit ? Link to comment Share on other sites More sharing options...
bubu Posted July 14, 2005 Report Share Posted July 14, 2005 (edited) $allow = array('tiri', 'tiri2', 'tiri3'); $page = 'tiri'; // defaultā if (isset($_GET['cat']) && in_array($_GET['cat'], $allow)) $page = $_GET['cat']; require_once($page.'.php'); Edited July 14, 2005 by bubu Link to comment Share on other sites More sharing options...
Venom Posted July 14, 2005 Report Share Posted July 14, 2005 klasiskais <? $includes=array('index'=>'sakums.php','blog'=>'dianasgramata.php'); include 'header.php'; if (isset($_GET['action']) && isset($includes[$_GET['action']])) include $includes[$_GET['action']]; include 'footer.php'; ?> paskaties arī switch() konstrukciju Link to comment Share on other sites More sharing options...
andrisp Posted July 14, 2005 Author Report Share Posted July 14, 2005 klasiskais<? $includes=array('index'=>'sakums.php','blog'=>'dianasgramata.php'); include 'header.php'; if (isset($_GET['action']) && isset($includes[$_GET['action']])) include $includes[$_GET['action']]; include 'footer.php'; ?> paskaties arī switch() konstrukciju 19336[/snapback] shitas ir ok, man patiik, liidziigi kaa es biju iedomaajies par to mysql, bet shitaa mazaaks chakars.. un viss vienaa vietaa. paldies Link to comment Share on other sites More sharing options...
andrisp Posted July 14, 2005 Author Report Share Posted July 14, 2005 hmm, es veel uztaisiiju, ka ja gadijumaa ieksh $includes neatrod neko, tad vinjs includo vienu defaulto lapu, piem, news.php, vai arii ja $includees ir, bet nav reaala faila uz servaka, tad arii inkludo to pashu news.php.. bet man nepatiik, ka ieksh URL laucinja taapat paliek nepareizi ievadiitais URL. header izmantot negribu. var veel kaa ? Link to comment Share on other sites More sharing options...
bubu Posted July 14, 2005 Report Share Posted July 14, 2005 (edited) mod_rewrite ja useris piemēram ievadīs http://servers.lv/kautkas/viens tad ar mod_rewrite palīdzību to var pārvērst uz (nu to ko apache īstenībā izpildīs) http://servers.lv/index.php?a=kautkas&b=viens Edited July 14, 2005 by bubu Link to comment Share on other sites More sharing options...
Klez Posted July 16, 2005 Report Share Posted July 16, 2005 var arii ar switch switch($_GET['page']){ case 1: include("sakums.php"); break; case 2: include("faili.php"); break; case 'blog': include("blog.php"); break; .... .... default: include("sakums.php"); } manupraat vienkaarsh variants .. :) Link to comment Share on other sites More sharing options...
bubu Posted July 17, 2005 Report Share Posted July 17, 2005 Ar switch vairāk jāraksta Link to comment Share on other sites More sharing options...
Recommended Posts