Module Website

From Dolibarr ERP CRM Wiki
Jump to navigation Jump to search

Return to user
documentation index

File Doc user.png

Return to
list of modules index


Numero/ID of module Website
User doc. of module This page
Developer doc. of module Module Website (developer)


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


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


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 Dolibarr 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, $langs, $weblangs, $website, $webpage

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 articles (container with type "blogpost"), 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">
            $keyword = 'mykeyword';
            $websitepage = new WebsitePage($db);
            $fuser = new User($db);
            $arrayofblogs = $websitepage->fetchAll($website->id, 'DESC', 'date_creation', 5, 0, array('type_container'=>'blogpost', 'keywords'=>$keyword));
            if (is_numeric($arrayofblogs) && $arrayofblogs < 0)
                print '<div class="error">'.$weblangs->trans($websitepage->error).'</div>';
            elseif (is_array($arrayofblogs) && ! empty($arrayofblogs))
                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>';
                                print '<li><span>by<span> <span class="text-primary">'.($fuser->firstname?$fuser->firstname:$fuser->login).'</span></span></li>';
                                print '</ul>';
                                print '</div>';
                                print '<span class="nohover">'.$blog->description.'</span>';
                                print '</a>';
                    print '</div>';
                    print '</div>';
                    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>';

Publish your website

To make your website live, you can click on the link "Publish". 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 Dolibarr application live, but the database must still remain started.