Website

Introduction

The module website add a CMS (Content Management System) inside Dolibar ERP CRM. You can create your own website inside Werpos, publish your website using an external web server like Apache and NGinx and reuse any data from your ERP CRM into our website.

Installation

This module is included with the Werpos distribution, so there is no need to install it.

Configuration

To use this module, you must first enable it using an administrator account, via the menu option “Home – Setup – Modules“.

Choose the tab where the module is listed. Then click on “Activate“.

The module is now activated.

If an icon appears at end of the line for the module, click on it to access the setup page specific to the module.

Create a new website

Go on top menu “Website” then use the button “New website” to initialize a new website. You are ready to add your fist page.

Add a new page / container

To add your first page, you can start a page from scratch or import an existing website/template that you can modify later.

Import a website template

This is the fastest way to get a website ready to publish. Click on “Import website”. Choose your template or upload a template from on a template market place or provided by your web agency.

Create a new page from scratch

Just click on the button “Add page/container”. Fill the meta information and “Save”. Now you can click on “Edit source” to add your HTML content. …

Add the content of a page/container into another page/container

Including a container into a parent container allows to move some content (text or html)of a page into a sub-page. So you can include it on several pages. Changing the content of the subpage will be propagated on any page that include the sub-page. It is similar to using the “Templates” with Mediawiki or using the #include in C++.

To include the content of a sub-page/sub-container into another one, just add this where you want to have the sub-content included:

<?php includeContainer(‘alias_of_container_to_include’); ?>

Add dynamic content into a page

One of the most interesting feature of Werpos CMS is that you can include dynamic content by adding PHP code, anywhere on your web site. Only restricted people do this because they need the permission “Add dynamic content” to be allowed to do that. Adding dynamic content is as easy as developping in PHP. Just add the <?php / ?> tags. You can use, in your dynamic code, any of the following predefined global variable (they are already initialized and populated):

$conf, $user, $db, $mysoc, $website, $websitepage, $weblangs, $pagelangs

Get properties of your company

This is example of dynamic content to get the name of your company:

<?php echo $mysoc->name; ?>

Get properties of the web page

This is another example of dynamic content to get meta data of a container/page:

__(Title)__ : <?php echo $websitepage->title; ?><br>
__(Description)__ : <?php echo $websitepage->description; ?><br>
__(Keywords)__ : <?php echo $websitepage->keywords; ?><br>
__(DateCreation)__ : <?php echo dol_print_date($websitepage->date_creation, 'dayhour', $weblangs); ?><br>

Latest Blog post

This is an example of a section to show the list of latest 5 active articles (container with type “blogpost”), in english, that contains the keyword “mykeyword”.

 <!-- Blog list -->
<section id="sectionnews" contenteditable="true" class="main section-50 section-md-50 section-md-bottom-50">
    <h2>Latest Blog posts</h2>
            <div class="center">
            <?php 
            $keyword = 'mykeyword';
            $weblangs->loadLangs(array("main"));
            $arrayofblogs = $websitepage->fetchAll($website->id, 'DESC', 'date_creation', 5, 0, array('type_container'=>'blogpost', 'keywords'=>$keyword, 'status'=>'1', 'lang'=>'en'));
            if (is_numeric($arrayofblogs) && $arrayofblogs < 0)
            {
                print '<div class="error">'.$weblangs->trans($websitepage->error).'</div>';
            }
            elseif (is_array($arrayofblogs) && ! empty($arrayofblogs))
            {
                $fuser = new User($db);
                foreach($arrayofblogs as $blog)
                {
                    print '<div class="row justify-content-sm-center row-40">';
                    print '<div class="container blog-box centpercent" style="padding: 20px; transition: .3s all ease;">';
                                print '<a href="'.$blog->pageurl.'.php">';
                                print '<div class="post-boxed-img-wrap"><img src="'.($blog->image ? 'viewimage.php?modulepart=medias&file='.$blog->image : 'medias/image/'.$website->ref.'/calendar.svg"').'" alt="" width="120"></div>';
                                print '<div class="post-boxed-caption">';
                                print '<div class="post-boxed-title font-weight-bold">'.$blog->title.'</div>';
                                print '<ul class="list-inline list-inline-dashed text-uppercase">';
                                print '<li>'.dol_print_date($blog->date_creation, 'daytext', 'tzserver', $weblangs).'</li>';
                                $fuser->fetch($blog->fk_user_creat);
                                print '<li><span>by<span> <span class="text-primary">'.($fuser->firstname?$fuser->firstname:$fuser->login).'</span></span></li>';
                                print '</ul>';
                                print '</div>';
                                //includeContainer($blog->pageurl);
                                print '<span class="nohover">'.$blog->description.'</span>';
                                print '</a>';
                    print '</div>';
                    print '</div>';
                }
            }
            else
            {
                    print '<div class="row justify-content-sm-center row-40">';
                    print '<div class="container blog-box centpercent" style="padding: 20px; transition: .3s all ease;">';
                    print $weblangs->trans("NoArticlesFoundForTheKeyword", $keyword);
                    print '</div>';
                    print '</div>';
                
            }
            ?>
            </div>
</section>

Create a custom 404 page

To create a custom 404 page, just create a common empty page with the name “404” and the type “page”. Then edit the HTML content of the page with the content of your choice, and add at the end the page

<?php http_response_code(404); ?>

Then you must edit your web server setup to tell to use this page as the 404 page. For example with Apache, add into your virtual host configuration:

ErrorDocument 404 /404.php

Deploy | Publish your website

To make your website live, you can click on the link “Deploy/Text my website”. A popup will show you instructions to setup the web server, like Apache, so you can make your website live on the Internet. When a website is lived, it is not necessary to have Werpos application live, but the database must still remain started.

Note: It is not possible to have your website and Werpos backoffice (that is itself a website tool) using the exactly same domain name. Indeed, it is thanks to the domain name that the web server (like Apache, Nginx, …) knows where to redirect the request (The Werpos Backoffice itself or the websote built by the CMS of Werpos). But you can choose the beginning of the name to differentiate them. For example, you can use:

Scripts

Script regenerate-pages.php