הרשם שאלות ותשובות רשימת חברים לוח שנה הודעות מהיום

חזור   הוסטס - פורום אחסון האתרים הגדול בישראל > עיצוב גראפי, תכנות על כל שפותיו וקידום ושיווק אתרים > פורום תיכנות

   
|!|

השב
 
כלים לאשכול תצורת הצגה
ישן 02-11-08, 12:05   # 1
vadimg88
חבר מתקדם
 
מיני פרופיל
תאריך הצטרפות: Feb 2008
גיל: 37
הודעות: 710

vadimg88 לא מחובר  

טעות קטנה בקוד זה אמור לעבוד:

PHP קוד:
<?php


$page 
trim(stripslashes($_GET['page']));
// $page = intval($page); // if the $page can be only a number uncomment this line


// the array of choices that can be used
# What to do?
$choice = array(
"contact"        => array( "contact"             'contact'       , array() ),
"page"         => array( "page"             'page'       , array() ),
"index"         => array( "index"             'index'       , array() ),

);


$page = isset($page) ? $page 'index';

if( 
is_array($page) )
{
    
$page 'idx';
}

# Check to make sure the array key exits..
if ( ! isset($choicestrtolower($page) ][0]) )
{
    
$page 'idx';
}

# Redirect to a page
header('Location: index.php?page='.$loaded);

# Load a file
# REQUIRE AND RUN
require( ROOT_PATH $choicestrtolower($page) ][0].".php" ); // load the file xx.php
$runme = new $choicestrtolower($page) ][1]; // call the class xx
$runme->auto_run(); // run it


// etc...



?>
שים לב ששמתי את האלמנט הראשון במערך. זאת אומרת שאם תיגש לקישור index.php?page=contact זה יפנה לקישור index.php?page=contact
במידה ויש לטעון קובץ זה יטען קובץ contact.php

Last edited by vadimg88; 02-11-08 at 12:08..
  Reply With Quote
ישן 02-11-08, 12:10   # 2
Jonathan Zeierman
חבר וותיק
 
מיני פרופיל
תאריך הצטרפות: Jun 2007
הודעות: 1,003

Jonathan Zeierman לא מחובר  

ציטוט:
נכתב במקור על ידי vadimg88 צפה בהודעה
טעות קטנה בקוד זה אמור לעבוד:

PHP קוד:
<?php


$page 
trim(stripslashes($_GET['page']));
// $page = intval($page); // if the $page can be only a number uncomment this line


// the array of choices that can be used
# What to do?
$choice = array(
"contact"        => array( "contact"             'contact'       , array() ),
"page"         => array( "page"             'page'       , array() ),
"index"         => array( "index"             'index'       , array() ),

);


$page = isset($page) ? $page 'index';

if( 
is_array($page) )
{
    
$page 'idx';
}

# Check to make sure the array key exits..
if ( ! isset($choicestrtolower($page) ][0]) )
{
    
$page 'idx';
}

# Redirect to a page
header('Location: index.php?page='.$loaded);

# Load a file
# REQUIRE AND RUN
require( ROOT_PATH $choicestrtolower($page) ][0].".php" ); // load the file xx.php
$runme = new $choicestrtolower($page) ][1]; // call the class xx
$runme->auto_run(); // run it


// etc...



?>
שים לב ששמתי את האלמנט הראשון במערך. זאת אומרת שאם תיגש לקישור index.php?page=contact זה יפנה לקישור index.php?page=contact
במידה ויש לטעון קובץ זה יטען קובץ contact.php
לא עובד,
http://www.zeierman.co.il/yoni/get.php
והנה הדף contact
http://www.zeierman.co.il/yoni/contact.php
__________________
יונתן.
אימייל: jonathan@zeierman.net
  Reply With Quote
ישן 02-11-08, 12:24   # 3
Ron | CSite.co.il
חבר על
 
מיני פרופיל
תאריך הצטרפות: Jun 2007
גיל: 33
הודעות: 980

Ron | CSite.co.il לא מחובר  

ואדים הקוד שלך ממש לא חכם,
בכל פעם שהוא ירצה עמוד חדש הוא יצטרך להכנס לדף ולהוסיף טקסט למערך , זה דיי טפשי.
הנה קובץ ה page שלי:

PHP קוד:
//Is this the main page?
if (isset($_GET['page']) && file_exists("sources/src_{$_GET['page']}.php")) 
{    
    
//If exists Class
    
if(file_exists("includes/{$_GET['page']}.class.php"))
        include_once(
"includes/{$_GET['page']}.class.php");
    
//Include sources
    
include_once("sources/src_{$_GET['page']}.php");
    
$template "tpl/master.tpl";
}
else {
    
//If exists Class
    
if(file_exists("includes/index.class.php"))
        include_once(
"includes/index.class.php");
    
//    
    
include_once("sources/src_index.php");
    
$template "tpl/master.tpl";
}
// 
בשביל להוסיף דף אתה פשוט פותח את הדף בתיקייה sources,
בנוסף אם תרצה קובץ מחלקה אתה פותח אותו בתקייה includes.
כמובן שהדף למעלה מאונקלד בתוך קובץ index שעושה פעולות נוספות שיש בהם צורך.

*היתרון הוא שאין צורך להיכנס לקובץ ה page במידה ואתה רוצה להוסיף דף /למחוק.
  Reply With Quote
השב

חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים)
 


חוקי פירסום
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is מופעל
סמיילים הם מופעל
[IMG] קוד מופעל
קוד HTML מכובה

קפיצה לפורום


כל הזמנים הם GMT +2. הזמן כעת הוא 12:26.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ