สอบถามการสร้าง templates ใน joomla

ถามตอบ ปัญหาการพัฒนา Extension ไม่ว่าจะเป็น Module plugin Component หรือ แม้แต่ template การปรับแต่งโค้ด Joomla ต่างๆ ทุกเวอร์ชั่น 1.5 2.5 หรือ 3.x

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
Thanapoom1514
PHP VIP Members
PHP VIP Members
โพสต์: 4329
ลงทะเบียนเมื่อ: 04/07/2022 9:46 am

สอบถามการสร้าง templates ใน joomla

โพสต์ที่ยังไม่ได้อ่าน โดย Thanapoom1514 »

ผมลองศึกษาในสร้างเทมเพลตการจากตัววิดีโอ Joomla template Develop สอนสร้าง เทมเพลต จูมล่า
เทมเพลตที่ผมลองทำครับ ลิงกนี้ครับ https://www.a4joomla.com/free-joomla-3- ... plate.html
ลิงก์วิดีโอที่ศึกษา https://youtu.be/ZGlTkym3Hsg
ผลลัพธ์ที่ได้ คือมันแสดงแค่หน้า Home และไม่ขึ้นโมดูลได้กำหนดเอาไว้ให้ครับ อยากทราบว่าทำไม่ขึ้นแค่นี้ครับ
Joomla Development-1.png
Joomla Development-1.png (7.46 KiB) Viewed 816 times
โค้ดใน index.php

โค้ด: เลือกทั้งหมด

<?php
/**
 * @package     Joomla.Site
 * @subpackage  Templates.protostar
 *
 * @copyright   (C) 2012 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

/** @var JDocumentHtml $this */

$app  = JFactory::getApplication();
$user = JFactory::getUser();

// Output as HTML5
$this->setHtml5(true);

// Getting params from template
$params = $app->getTemplate(true)->params;

// Detecting Active Variables
$option   = $app->input->getCmd('option', '');
$view     = $app->input->getCmd('view', '');
$layout   = $app->input->getCmd('layout', '');
$task     = $app->input->getCmd('task', '');
$itemid   = $app->input->getCmd('Itemid', '');
$sitename = htmlspecialchars($app->get('sitename'), ENT_QUOTES, 'UTF-8');

// Add JavaScript Frameworks
JHtml::_('bootstrap.framework');


// Add template js
JHtml::_('script', 'template.js', array('version' => 'auto', 'relative' => true));
JHtml::_('script', 'jquery.sidr.js', array('version' => 'auto', 'relative' => true));
JHtml::_('script', 'jquery.sidr.min.js', array('version' => 'auto', 'relative' => true));


// Add html5 shiv
JHtml::_('script', 'jui/html5.js', array('version' => 'auto', 'relative' => true, 'conditional' => 'lt IE 9'));

// Add Stylesheets
JHtml::_('stylesheet', 'all.css', array('version' => 'auto', 'relative' => true));
JHtml::_('stylesheet', 'editor.css', array('version' => 'auto', 'relative' => true));
JHtml::_('stylesheet', 'jquery.sidr.dark.css', array('version' => 'auto', 'relative' => true));
JHtml::_('stylesheet', 'template.css', array('version' => 'auto', 'relative' => true));
JHtml::_('stylesheet', 'template-pirnt.css', array('version' => 'auto', 'relative' => true));
JHtml::_('stylesheet', 'all.min.css', array('version' => 'auto', 'relative' => true));

// Use of Google Font
if ($this->params->get('googleFont'))
{
	$font = $this->params->get('googleFontName');

	// Handle fonts with selected weights and styles, e.g. Source+Sans+Condensed:400,400i
	$fontStyle = str_replace('+', ' ', strstr($font, ':', true) ?: $font);

	JHtml::_('stylesheet', 'https://fonts.googleapis.com/css?family=' . $font);
	$this->addStyleDeclaration("
	h1, h2, h3, h4, h5, h6, .site-title {
		font-family: '" . $fontStyle . "', sans-serif;
	}");
}

// Template color
if ($this->params->get('templateColor'))
{
	$this->addStyleDeclaration('
	body.site {
		border-top: 3px solid ' . $this->params->get('templateColor') . ';
		background-color: ' . $this->params->get('templateBackgroundColor') . ';
	}
	a {
		color: ' . $this->params->get('templateColor') . ';
	}
	.nav-list > .active > a,
	.nav-list > .active > a:hover,
	.dropdown-menu li > a:hover,
	.dropdown-menu .active > a,
	.dropdown-menu .active > a:hover,
	.nav-pills > .active > a,
	.nav-pills > .active > a:hover,
	.btn-primary {
		background: ' . $this->params->get('templateColor') . ';
	}');
}




// Logo file or site title param
if ($this->params->get('logoFile'))
{
	$logo = '<img src="' . htmlspecialchars(JUri::root() . $this->params->get('logoFile'), ENT_QUOTES) . '" alt="' . $sitename . '" />';
}
elseif ($this->params->get('sitetitle'))
{
	$logo = '<span class="site-title" title="' . $sitename . '">' . htmlspecialchars($this->params->get('sitetitle'), ENT_COMPAT, 'UTF-8') . '</span>';
}
else
{
	$logo = '<span class="site-title" title="' . $sitename . '">' . $sitename . '</span>';
}
?>
<!DOCTYPE html>
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">

<head>
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<jdoc:include type="head" />
</head>
<body>
<?php if ( 1 == $isheader  && 1 == $showHeader ) : ?>
  <div id="headerwrap">
<?php else : ?>  
  <div id="navwrap">
<?php endif; ?>
	<div id="navcontainer" class="container-fluid">      
		<div id="navflex" class="row-fluid">
			<div id="logo">
					<h2><a href="<?php echo JURI::base(); ?>" title="<?php echo htmlspecialchars($logoText); ?>"><?php echo htmlspecialchars($logoText); ?></a></h2>
					<h3><?php echo htmlspecialchars($slogan); ?></h3> 
			</div>
			<div id="navright" >
		
				<div id="topmenu" class="navbar navbar-inverse">
					<div id="topnav" class="navbar-inner">
						<div id="myoverlay"></div>
						<a id="menu-button" href="#sidr" class="fa fa-bars" >

						</a>
						<div id="sidr" >
							<a href="#" id="myclosebtn" >&times;</a>
							<?php if ( $feedurl || $facebookurl || $twitterurl || $youtubeurl || $contacturl || $searchurl || $button ) : ?>
							<div id="soci2">
							<?php if($feedurl) : ?>
								<a target="_blank" class="myfeed" href="<?php echo $feedurl; ?>" title="Feed"><i class="fas fa-rss"></i></a>
							<?php endif; ?>
							<?php if($facebookurl) : ?>
								<a target="_blank" class="myfacebook" href="<?php echo $facebookurl; ?>" title="Facebook"><i class="fab fa-facebook-f"></i></a>
							<?php endif; ?>
							<?php if($twitterurl) : ?>
								<a target="_blank" class="mytwitter" href="<?php echo $twitterurl; ?>" title="Twitter"><i class="fab fa-twitter"></i></a>
							<?php endif; ?>
							<?php if($youtubeurl) : ?>
								<a target="_blank" class="myyoutube" href="<?php echo $youtubeurl; ?>" title="Youtube"><i class="fab fa-youtube"></i></a>
							<?php endif; ?>
							<?php if($contacturl) : ?>
								<a class="mycontact" href="<?php echo $contacturl; ?>" title="Contact"><i class="far fa-envelope"></i></a>
							<?php endif; ?>
							<?php if($searchurl) : ?>
								<a class="mysearch" href="<?php echo $searchurl; ?>" title="Search"><i class="fa fa-search"></i></a>
							<?php endif; ?>
							<?php if($button) : ?>
									<a class="btn button-menu2 mybutton" href="<?php echo $button; ?>" title=""><?php echo $buttontxt; ?></a>
							<?php endif; ?>
							</div>
							<?php endif; ?>
							<?php if($this->countModules('position-1')) : ?>
								<jdoc:include type="modules" name="position-1" style="none" />
							<?php endif; ?>
						</div>
					</div>	
					<div id="soci">
						<?php if($feedurl) : ?>
							<a target="_blank" class="myfeed" href="<?php echo $feedurl; ?>" title="Feed"><i class="fas fa-rss"></i></a>
						<?php endif; ?>
						<?php if($facebookurl) : ?>
							<a target="_blank" class="myfacebook" href="<?php echo $facebookurl; ?>" title="Facebook"><i class="fab fa-facebook-f"></i></a>
						<?php endif; ?>
						<?php if($twitterurl) : ?>
							<a target="_blank" class="mytwitter" href="<?php echo $twitterurl; ?>" title="Twitter"><i class="fab fa-twitter"></i></a>
						<?php endif; ?>
						<?php if($youtubeurl) : ?>
							<a target="_blank" class="myyoutube" href="<?php echo $youtubeurl; ?>" title="Youtube"><i class="fab fa-youtube"></i></a>
						<?php endif; ?>
						<?php if($contacturl) : ?>
						<a class="mycontact" href="<?php echo $contacturl; ?>" title="Contact"><i class="far fa-envelope"></i></a>
						<?php endif; ?>
						<?php if($searchurl) : ?>
							<a class="mysearch" href="<?php echo $searchurl; ?>" title="Search"><i class="fa fa-search"></i></a>
						<?php endif; ?>
						<?php if($button) : ?>
							<a class="btn button-menu mybutton" href="<?php echo $button; ?>" title=""><?php echo $buttontxt; ?></a>
						<?php endif; ?>
					</div>
					
				</div> 
				
			</div>
		</div>
	</div>
	<?php if ( 1 == $isheader && 1 == $showHeader ) : ?>  
	<header id="masthead" >
			<?php if ( $headerText ) : ?>
				<h2 class="fullpageheader"><?php echo $headerText; ?></h2>
			<?php endif; ?>
			<?php if ( $headerDesc ) : ?>
				<h3 class="fullpageheader"><?php echo $headerDesc; ?></h3>
			<?php endif; ?>
			<?php if ( $buttonText ) : ?>
				<a href="<?php echo $buttonURL; ?>" class="btn fullpageheader"><?php echo $buttonText; ?></a>
			<?php endif; ?>

	</header><!-- #masthead -->	
	<?php endif; ?>
</div>
<?php if ( 0 == $isheader || 0 == $showHeader ) : ?>
<div id="navsepwrap">
	<div id="navsepcontainer" class="container-fluid">
		<div id="navsep" class="dottedbg"></div>
	</div>
</div>
<?php endif; ?>

<div id="allwrap" >

	<div id="wrap" class="container-fluid" >

		<?php if($this->countModules('position-2')) : ?>
			<div id="pathway">
				<jdoc:include type="modules" name="position-2" />
			</div>
		<?php endif; ?> 
		<div id="cbody" class="row-fluid">
			<?php if($showLeftColumn) : ?>
				<div id="sidebar" class="span<?php echo $leftColumnWidth; ?>">     
					<jdoc:include type="modules" name="position-7" style="xhtml" />    
				</div>
			<?php endif; ?>
			<div id="content60" class="span<?php echo $contentWidth; ?>">    
				<div id="content">
					<jdoc:include type="message" />
					<jdoc:include type="component" /> 
				</div> 
			</div>
			<?php if($showRightColumn) : ?>
				<div id="sidebar-2" class="span<?php echo $rightColumnWidth; ?>">     
					<jdoc:include type="modules" name="position-6" style="xhtml" />     
				</div>
			<?php endif; ?>
		</div>
  
<!--end of wrap-->
	</div>
    
<!--end of allwrap-->
</div>

<div id="footerwrap"> 
	<div id="footer" class="container-fluid">  
		<div class="row-fluid">
			<?php if($this->countModules('position-14')) : ?>	
				<jdoc:include type="modules" name="position-14" style="xhtml" />    
			<?php endif; ?>
		</div>
	</div>
	<div id="a4j" class="container-fluid"><a href="http://a4joomla.com/"><?php echo JText::_('TPL_A4JOOMLA-DARK-FREE_FOOTER_LINK_TEXT');?></a></div> 
</div>
</body>
</html>
:gfb:
ภาพประจำตัวสมาชิก
tsukasaz
PHP VIP Members
PHP VIP Members
โพสต์: 21992
ลงทะเบียนเมื่อ: 18/04/2012 9:39 am

Re: สอบถามการสร้าง templates ใน joomla

โพสต์ที่ยังไม่ได้อ่าน โดย tsukasaz »

เช็คก่อนครับว่า กำหนดตำแหน่งให้ module ถูกต้องไหม เพราะ template แต่ละตัวอาจใช้ชื่อตำแหน่งไม่เหมือนกัน
The last bug isn't fixed until the last user is dead. (Sidney Markowitz, 1995)
ภาพประจำตัวสมาชิก
Thanapoom1514
PHP VIP Members
PHP VIP Members
โพสต์: 4329
ลงทะเบียนเมื่อ: 04/07/2022 9:46 am

Re: สอบถามการสร้าง templates ใน joomla

โพสต์ที่ยังไม่ได้อ่าน โดย Thanapoom1514 »

ได้แล้วครับ ผมใส่ params ของ template ที่เอามาทดลองแล้วมาใส่ templateของตัวเองที่ทำขึ้น ก็ขึ้นแสดงโมดูลขึ้นมาให้ครับ
Joomla Development-1.png
Joomla Development-1.png (46.17 KiB) Viewed 779 times
:gfb:
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 101