Module Sites web

From Dolibarr ERP CRM Wiki
Revision as of 16:37, 31 October 2020 by PolyglotBot (talk | contribs) (Updating interlang links (links to translated versions of this page in other languages) triggered by origin English page "Module_Website_FR" update.)
Jump to navigation Jump to search
{{{nom}}}
Numéro/ID du module Website
Doc utilisateur du module This page
Doc développeur du module Module Website (developer)

En verysmall.png Page waiting for translation. To translate, create an account, go back and clic on "Modify".
Fr verysmall.png Page en attente de traduction. Pour traduire, créez un compte, revenez et cliquez sur "Modifier".
Es verysmall.png Página a traducir. Para traducirla, cree una cuenta, vuelva a la página y haga clic en "editar".
It verysmall.png Pagina da tradurre. Per tradurla, crea un utente, torna indietro e clicca su "modifica".
Pt verysmall.png Página a aguardar por tradução. Para traduzir, crie uma conta, volte atrás e clique em "Modificar".
De verysmall.png Seite wartet auf Übersetzung. Um Übersetzung zu erstellen, richte einen Account ein, geh zurück und klicke auf "bearbeiten".
Zh verysmall.png 页面等待翻译。若要翻译本页,先创建一个帐户、登录并返回本页后单击“编辑”。

Introduction

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.

Installation

This module is included with the Dolibarr 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 a cog icon appears Cog circle.svg on module thumb or at end of the line of 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, $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>

Read another remote Dolibarr database

Just create a remote database connection and then, use this one for your SQL requests

global $dbmaster;
$dbmaster = getDoliDBInstance('mysqli', 'myserver', 'userread', 'abcdef', 'databasename', 3306);
$confmaster = new Conf();
if ($dbmaster) $confmaster->setValues($dbmaster);

Note: You can also decide to use the APIs.

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 Dolibarr application live, but the database must still remain started.

Note: It is not possible to have your website and Dolibarr 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 Dolibarr Backoffice itself or the websote built by the CMS of Dolibarr). But you can choose the beginning of the name to differentiate them. For example, you can use:


Scripts