Forum for discussing general topics related to Couch.
17 posts Page 1 of 2
Hi

I have a customer who wants to be able to edit parts of the includes/header.php and includes/footer.php files such as menu link names and add new links to it

I know it can be done as asked the question before and it's done by using globals and found ways to do it via Google search but just seeing the best way to do it, the methods I found are below

1) Put the contents of the includes/header.php file into a file called header.html and put that into the snippets folder and then embed the file into the index.php file using
Code: Select all
<cms:embed 'header.html' />


2) I found this method: viewtopic.php?f=2&t=2783

Bit confused by it as not done it for a few years and can't remember best way to do it

Thank you in advance
Hi,

By using the first option you listed above, you'll be able to include the contents of header.php (now header.html) into other templates.

That would, however, be the same as using PHP 'include'.
It still wouldn't allow you to make contents of the header editable.
For doing that, you'll have to use the technique described in the second option you listed (i.e. use globals).

Hope this helps.
Hi

Ahh ok, so the better option is the second one using globals and with that the menu link names can be editable and the user could add new links to the menu, that right?
Ive got stuck with globals.php and need some help

I have created the globals.php file and added the following coding to the globals.php file and uploaded it to the root

Code: Select all
<?php require_once ( 'cms/cms.php' ); ?>
<cms:template title='Global Settings' executable='0'>

</cms:template>
<!DOCTYPE html>
<html lang="en">

<head>
    <title><?php echo $title; ?></title>
    <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="<?php echo $pgDesc ?>">
   <link rel="stylesheet" href="./css/main.css" type="text/css" media="screen">
</head>
<body class="home cbp-so-scroller" id="cbp-so-scroller">

<!-- Mobile Menu  -->
<div class="header">
  <a href="#menu" class="button">menu</a>
  <a href="contact.php" class="btn">free quote</a>     
  <a class="tell" href="tel:"><span>Call</span> </a>
</div>

<div id="menu" >
  <ul class="menu_snap">
    <li><a href="index.php">Home</a></li>
    <li><a href="services.php">Services</a></li>
    <li><a href="sales.php">Sales</a></li>
    <li><a href="reviews.php">Reviews</a></li>
    <li><a href="contact.php">Contact</a></li>
  </ul>
</div>

<div class="site-container" id="home">
 
<!-- Header -->
<header class="site-header">
   <a href="index.php" class="logo"><img src="images/logo/nicom-logo-transparent.png" alt=""></a>
   <div class="top-header">
    <a href="contact.php" class="btn">free quote</a>     
    <p class="phone">
      <i class="fa fa-phone" aria-hidden="true"></i>
      <a href="tel:"></a>
    </p>
    <p class="companyname">
   
    </p>
    <ul class="socials">
      <li><a href="" target="_blank"><i class="fa fa-facebook" aria-hidden="true"></i></a></li>
      <li><a href="#" target="_blank"><i class="fa fa-twitter" aria-hidden="true"></i></a></li>
      <li><a href="#" target="_blank"><i class="fa fa-linkedin" aria-hidden="true"></i></a></li>
      <li><a href="#" target="_blank"><i class="fa fa-pinterest" aria-hidden="true"></i></a></li>
    </ul>

   </div>

  <!-- N A V  -->
  <nav id="nav" class="nav-primary" >

      <ul class="sf-menu menu menu_snap" id="sf-menu">
        <li><a href="index.php">Home</a></li>
       <li><a href="services.php">Services</a></li>
        <li><a href="sales.php">Sales</a></li>
        <li><a href="reviews.php">Reviews</a></li>
        <li><a href="contact.php">Contact</a></li>
      </ul>

  </nav>

</header>
<?php COUCH::invoke(); ?>


In index.php file, I have added the following coding

Code: Select all
<?php require_once ( 'cms/cms.php' ); ?>
<cms:template title='Home' executable='0'>

</cms:template>

<cms:get_custom_field 'site_name' masterpage='globals.php' />


When I visit index.php, it don't show the header such as the nav menu etc. and I am unsure how to add the menu links to the couch cms admin side in global settings, it currently says No Editable Regions defined

To confirm the user wants to be able to change the menu items links and names
Still trying to work it out going by this link: viewtopic.php?f=2&t=2783

I have just added the code below to my globals.php file

Code: Select all
<cms:editable name='menu_code' label="Menu code" 
       height='100'
       no_xss_check='1'
       type="textarea"
/>


so it now looks like below

Code: Select all
<?php require_once ( 'cms/cms.php' ); ?>
<cms:template title='Global Settings' executable='0'>
<cms:editable name='menu_code' label="Menu code"
       height='100'
       no_xss_check='1'
       type="textarea"
/>
</cms:template>
<!DOCTYPE html>
<html lang="en">

<head>
    <title><?php echo $title; ?></title>
    <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="<?php echo $pgDesc ?>">
   <link rel="stylesheet" href="./css/main.css" type="text/css" media="screen">
</head>
<body class="home cbp-so-scroller" id="cbp-so-scroller">

<!-- Mobile Menu  -->
<div class="header">
  <a href="#menu" class="button">menu</a>
  <a href="contact.php" class="btn">free quote</a>     
  <a class="tell" href="tel:"><span>Call</span> </a>
</div>

<div id="menu" >
  <ul class="menu_snap">
    <li><a href="index.php">Home</a></li>
    <li><a href="services.php">Services</a></li>
    <li><a href="sales.php">Sales</a></li>
    <li><a href="reviews.php">Reviews</a></li>
    <li><a href="contact.php">Contact</a></li>
  </ul>
</div>

<div class="site-container" id="home">
 
<!-- Header -->
<header class="site-header">
   <a href="index.php" class="logo"><img src="images/logo/nicom-logo-transparent.png" alt=""></a>
   <div class="top-header">
    <a href="contact.php" class="btn">free quote</a>     
    <p class="phone">
      <i class="fa fa-phone" aria-hidden="true"></i>
      <a href="tel:"></a>
    </p>
    <p class="companyname">
   
    </p>
    <ul class="socials">
      <li><a href="" target="_blank"><i class="fa fa-facebook" aria-hidden="true"></i></a></li>
      <li><a href="#" target="_blank"><i class="fa fa-twitter" aria-hidden="true"></i></a></li>
      <li><a href="#" target="_blank"><i class="fa fa-linkedin" aria-hidden="true"></i></a></li>
      <li><a href="#" target="_blank"><i class="fa fa-pinterest" aria-hidden="true"></i></a></li>
    </ul>

   </div>

  <!-- N A V  -->
  <nav id="nav" class="nav-primary" >

      <ul class="sf-menu menu menu_snap" id="sf-menu">
        <li><a href="index.php">Home</a></li>
       <li><a href="services.php">Services</a></li>
        <li><a href="sales.php">Sales</a></li>
        <li><a href="reviews.php">Reviews</a></li>
        <li><a href="contact.php">Contact</a></li>
      </ul>

  </nav>

</header>
<?php COUCH::invoke(); ?>


On the couch cms admin side, it's got Global Settings and it now has a textarea box that says menu code, this is where I get stuck and confused as can't see the existing menu links to change them and the names

It says the following, I did the first bit of visiting globals.php while logged in as super admin, the user does not know coding so need to see the current menu links and names and be able to change them

"Visit globals.php while logged-in as super-admin for Couch to pickup the changes.
In the admin panel you can now add the HTML code for each of the previously included files into their respectable editable regions.

To include the code entered within the editable regions created above into the rest of the templates of your site, use the cms:get_custom_field tag. e.g. change the
Code:
<?php include("menu.php"); ?>
or
<cms:embed "menu.php" />
in each of your templates to
Code:
<cms:get_custom_field 'menu_code' masterpage='globals.php' />"

Am really confused on this
I found this link: viewtopic.php?f=8&t=11102 but not sure if will work if I have a header.php file or globals.php file

sorry just really stuck with this and not sure how to do it so the user can change the current menu item names and links if need be as he would like alot of control on the site and change most things himself
Can someone help please asap as really don't understand it and need to get it done quite quick, sorry

I have tried looking at it again but don't get it and tried looking on Google but can't find nothing apart from the links I found already, I really don't understand how the menu item names and links in the nav menu can be changed by the admin side in couchcms, can someone help with the coding please as got no idea and getting a headache looking at it
Could it be done with nested pages, for example my home page has a different design to the other 4 pages on the site so could could the home page have it's own design and the other 4 have the same design but different content so could I use nested pages and clone the 4 pages that have the same design and the home page have a different design

Hope someone can help as really stuck on this and need it done for the morning
The documentation for nested-pages (https://docs.couchcms.com/concepts/nest ... maker.html) says "Nested Pages (AKA Menu Maker)" - so sure, you may use it to create the menu structure for your site.
ok, how do I integrate it into the pages I have already created?

The pages I have already created and done the design for are below

Home Page
Services
Sales
Reviews
Contact

The Sales and Services pages have the same design

The reviews page is the same design as Sales apart from a sidebar is not included on the right side

The contact page has two columns, on the left is the contact form and the right is the google maps
17 posts Page 1 of 2
cron