简体   繁体   中英

Include PHP file in joomla template

<?php if ($this->countModules('position-7')): ?>

  <nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      <a class="navbar-brand" href="#">WebSiteName</a>
    </div>
    <div>
      <ul class="nav navbar-nav">
        <li class="active">  <a href="#" > Home </a> </li>
        <li> <a href="<?php include_once('templates/'.$this->template.'../test.php'); ?>"> page </a></li>

        <li><a href="#">Page 2</a></li>
        <li><a href="#">Page 3</a></li>
      </ul>
    </div>

    <jdoc:include type="modules" name="position-7" style="none" />
  </div>

</nav>
<?php endif; ?> 

I am new in joomla template edit index.php file and added the menu and insert external php file test.php

trying this way getting on error.

Forbidden

You don't have permission to access /joomla_site/test my code on this server. Apache/2.4.9 (Win32) PHP/5.5.12 Server at localhost Port 80

Why you're doing with external PHP files. ?

you need to create some menu items right ? first you have login to admin section and add some menu types and menu items. the check the site front end it will shows there. If you need some custom styles and all simply add extra classes on the menu item adding section.

you need a separate menu section than Joomla already have, simply create a module and assign that to a position , read the menu items from DB inside the module instead of including php file.

Joomla already have a module for rendering menu items you can reuse that.

hope its make sense..

do some research before doing mixing core php with joomla.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM