|
 |
|
ขอถามเรื่อง การทำ theme ให้กับเว็บของตัวเอง พอดีผมได้ทำโปรเจคจบ เป็นระบบเว็บสำเร็จรูปตัวนึง |
|
 |
|
|
 |
 |
|
แล้วอะไรเลิศหรูหว่า ถ้าไอ้ที่ว่ามามันไม่เลิศหรู เอิ๊ก ๆ
ถ้าจะทำแบบมีโมดูล ต้องเขียนสคริปกลาง (core) ไว้คอยรับการเรียกเป็นโมดูลหละครับ
ส่วนเรื่อง theme ก็เขียนกำหนดใน core ถ้าถามว่า เขียนยังไง มันเรื่องยาวจริง ๆครับ
มันแล้วแต่เราจะออกแบบมันยังไงด้วย
เราจะให้มันติดตั้งโมดูลเองเมื่อก้อบปี้ไปไว้ในโฟลเดอร์เอง แล้วแสดงขึ้นทันทีในระบบแอดมิน อะไรพวกนี้
มันเรื่องยาว และการเขียนโค๊ดที่ซับซ้อนพอควรครับ ต้องเขียนเป็น class functions หละครับ ไม่งั้นการเรียกใช้งาน
ที่ซ้ำ ๆ กันมันจะลำบาก เขียนโค๊ดกันอีก
ผมไม่รู้จะแนะนำตรงใหนอ่ะ เพราะระบบมัน ซับซ้อนเกินกว่าจะเขียนให้หมด ภายในอันดียวได้
ลองศึกษา พวกเว็บสำเร็จรูปที่ฮิต ๆในขณะนี้ดูครับ
|
 |
 |
 |
 |
Date :
2009-10-26 18:12:05 |
By :
deawx |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันมีหลายเทคนิคครับ  
อันนี้ตัวอย่างการเปลี่ยน theme แต่ไม่ใช่โหลดจาก module น่ะ
Code (PHP)
<script>
function setColor(){
var cbody =document.getElementById('bodyColor').value;
var imgbody =document.getElementById('bodyImgs').value;
var repBody = getCheckedValue(document.setTheme.repBodyImgs);
var cblock=document.getElementById('blockColor').value;
var imgblock =document.getElementById('blockImgs').value;
var repBlock = getCheckedValue(document.setTheme.repBlockImgs);
if(cbody=="other") cbody=document.getElementById('otherBodyColor').value;
if(cblock=="other") cblock=document.getElementById('otherBlockColor').value;
document.getElementsByTagName('body')[0].style.background =cbody+" url("+imgbody+") "+repBody+" left top";
document.getElementById('block').style.background=cblock+" url("+imgblock+") "+repBlock+" left top";
}
function createTextbox(box,val){
var tep= document.getElementById(box);
if(val=="other"){
tep.innerHTML = 'ใส่รหัสสีที่ต้องการ<input type="text" id="'+box+'Color" value="#"/>'
}else{
tep.innerHTML ="";
}
}
function getCheckedValue(radioObj) {
if(!radioObj)
return "";
var radioLength = radioObj.length;
if(radioLength == undefined)
if(radioObj.checked)
return radioObj.value;
else
return "";
for(var i = 0; i < radioLength; i++) {
if(radioObj[i].checked) {
return radioObj[i].value;
}
}
return "";
}
</script>
<style>
body{
background:#FFFFFF ;
}
#block{
height:200px;
background:#FF0066
}
</style>
<body>
<div id=block>
นี่คือ block
</div>
<form name="setTheme">
<b>Body</b><br/>
<u>รูป:</u><br/>
<input type="text" id="bodyImgs"> ใส่ url <br/>
<u>Repeat:</u><br/>
<input type="radio" name="repBodyImgs" id="repBodyImgs" value="repeat" checked>repeat xy
<input type="radio" name="repBodyImgs" id="repBodyImgs" value="repeat-x">repeat x
<input type="radio" name="repBodyImgs" id="repBodyImgs" value="repeat-y">repeat y
<br/>
<u>color:</u><br/>
<select id="bodyColor" onchange="javascript:createTextbox('otherBody',this.value)">
<option value="red">Red</option>
<option value="blue">blue</option>
<option value="black">Black</option>
<option value="other" >Other</option>
</select>
<span id="otherBody"></span><br/><br/>
<b>Block</b><br/>
<u>รูป:</u><br/>
<input type="text" id="blockImgs"> ใส่ url <br/>
<u>Repeat:</u><br/>
<input type="radio" name="repBlockImgs" id="repBlockImgs" value="repeat" checked>repeat xy
<input type="radio" name="repBlockImgs" id="repBlockImgs" value="repeat-x">repeat x
<input type="radio" name="repBlockImgs" id="repBlockImgs" value="repeat-y">repeat y
<br/>
color:<select id="blockColor" onchange="javascript:createTextbox('otherBlock',this.value)">
<option value="red">Red</option>
<option value="blue">blue</option>
<option value="black">Black</option>
<option value="other" >Other</option>
</select>
<span id="otherBlock"></span><br/>
<input type="button" value="ok" onclick="javascript:setColor()">
</form>
</body>
|
 |
 |
 |
 |
Date :
2009-10-26 18:59:11 |
By :
xbeginner01 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Thank ครับคุณ xbeginner01 
|
 |
 |
 |
 |
Date :
2009-10-27 10:30:12 |
By :
panyapol |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|