How to prepare your Gentics CMS project for Gentics Portal.Node PHP

This chapter describes

1 Demo CMS and Demo Portal

Please visit our demo for finding a bunch of good examples on how to integrate the Gentigcs CMS with the portal and how to get the most out of our software.

Gentics Portal.Node PHP demo

2 Gentics Content.Node (CMS)

You need Gentics Content.Node as your CMS (Content Management System). Visit our product page for further information.

2.1 CMS project (node)

You need to create a new node for your project in the CMS. This node must have the following settings:

  • Publish into filesystem
  • Update ContentRepository

If you do not need any personalisation you can also use publish into filesystem without the Gentics Content Repository. In this case you can’t use the personalisation, navigation modules, personalized overviews. These modules depend on a publishing into the Gentics Content Repository.

We recommend publishing into filesystem AND updating the Gentics Content Repository.

Set the option “URL Rendering” to “Static URLs (dynamic)” in the CR Publishing options of your node in order to allow the mapping of Portal.Node PHP URLs to CMS pages. Without this setting it will not work.

2.2 Object properties

These folder object.properties are needed in combination with the portal. Most of them are default object properties of Gentics Content.Node.

Navigation:

  • object.sortorder (for sorting navigations)
  • object.startpage (for defining start pages of navigation entries)
  • object.name_<language> (translation of navigation entries)
  • object.navhidden (hide entry in navigation)
  • object.hideinsearch (depends on your Gentics Content Connector search configuration – won’t be displayed in search results)
  • object.permissions (multivalue dropdown – datasource) – the keywords of your permissions MUST match the keywords of the personalization attributes in user administration (portal web interface) <portal>/user/admin/admin

2.3 Gentics Content Repository (CR) attributes

To define which content attributes are synced from the CMS to the Gentics Content Repository, you must use the TagmapEditor. Detailed documentation on these CMS functionalities you’ll find in the Gentics Infoportal

Check our demo CMS for further examples. We show you all attributes here which are not reserved:

Definition of columns:

  • Name of attribute in CR / tag-definition in CMS / object type (10002 = folder, 10007 = page, 10008 = binary) / Type of attribute / Multivalue / Optimized
  • startpageurl_en object.startpage.url.target.languageset.pages.en.url 10002 Folder 1 Text (short) No No
  • startpageurl_de object.startpage.url.target.languageset.pages.de.url 10002 Folder 1 Text (short) No No
  • hideinsearch object.hideinsearch 10002 Folder 3 Integer No Yes Navigation
  • tagging tagging.tags 10007 Page 1 Text (short) No No
  • hideinsearch object.hideinsearch 10007 Page 3 Integer No Yes Navigation
  • hideinsearch object.hideinsearch 10008 File 3 Integer No Yes Navigation
  • title title 10007 Page 1 Text (short) No No Content
  • entry_media entry_media 10007 Page 5 Text (long) No No Content
  • creationdate page.creationdate 10007 Page 1 Text (short) No No
  • teaser teaser 10007 Page 5 Text (long) No No Content
  • hideinoverview object.hideinoverview 10007 Page 3 Integer No No Content
  • sortorder object.sortorder 10002 Folder 1 Text (short) No No
  • startpage object.startpage.url.target.id 10002 Folder 10007 Page 2 Object No No
  • name_de object.name_de 10002 Folder 1 Text (short) No No
  • name_en object.name_en 10002 Folder 1 Text (short) No No
  • navhidden object.navhidden 10002 Folder 3 Integer No Yes Navigation
  • permissions object.permissions.permissions.selection 10002 Folder 1 Text (short) Yes No navigation
  • permissions object.permissions.permissions.selection 10007 Page 1 Text (short) Yes No navigation
  • permissions object.permissions.permissions.selection 10008 File 1 Text (short) Yes No navigation
  • startpageurl object.startpage.url 10002 Folder 1 Text (short) No No

For more performance make sure, that following reserved attributes are optimized:

  • url
  • node_id
  • name
  • filename
  • contentid
  • languagecode
  • mimetype
  • obj_type

Check if binarycontent is created for binary documents (10008-objects)!!!

2.4 Content elements in the CMS (Tagtypes)

If you want to integrate widgets into your content pages, you can find examples in the Demo CMS .

All tagtypes which integrate widgets are beginning with [Portal].

Information on how to integration widgets and widgets available

2.5 Example of widget code for usage in CMS content page

Please visit our Demo CMS and take a deep look at all tagtypes starting with “[Portal]”, there you get plenty of real life examples on how to include widgets into CMS.

This code will only be evaluated when the widget is displayed in the portal frontend. This code won’t be execute in the CMS!


## show this widget only if editor wants to include it in the page
#if ( "$cms.tag.parts.show" == "1" )##
## do not show PHP code in CMS backend
#if ( $cms.rendermode.publish != true )##
$cms.tag.parts.alternative
## PHP code will only be shown in publish mode
#else##
##exclude PHP code from being indexed by Apache Lucene! otherwise you'll see PHP code in results
<!--noindexstart-->
<!-- currently all portal modules are excluded from search indexing -->
<?php 
## this widget will be controlled by the parameters the editor sets in the tagtype 
$this->widget('comments.widgets.CommentsWidget', 
array(
  'contentId'=>'$cms.page.id', 
  'moderatorEmail' =>'$cms.page.publisher.email', 
  'notifyModeratorOnNew' => #if ( $cms.tag.parts.moderator == '1' ) true #else false #end, 
  'allowAnonymous' => #if ( $cms.tag.parts.anonymous == '1' ) true #else false #end,
  'paginationPagesCount' => 3,
  'commentsPerPage' => 10,
  'oneLevelReply' => #if ( $cms.tag.parts.threaded == '1' ) true #else false #end,
  'dontNeedApprove' => #if ( $cms.tag.parts.noapprove == '1' ) true #else false #end
));

?>
## end of not indexing
<!--noindexend-->
#end##

#end## show clause

2.6 Code for showing preview of widgets in the CMS

In the CMS itself PHP code won’t be evaluate due to security reasons. This is why we implemented in all “Portal” tagtypes a functionality for requesting a preview of the widget from the portal frontend.

Because JavaScript does not allow Ajax calls to request content from another domain, you have to use the proxy which must be placed on the webserver of the CMS. An example is in the Demo CMS in the folder “Templates” / “Proxy”. You have to configure the portal frontend URL in the proxy.

If you use Velocity in your tagtypes, you can request the preview via this code:


#if ( $cms.rendermode.publish != true )##
<script language="JavaScript">
$.ajax({
  url: "/gcnproxyreal/?url=/comments/preview/CommentsWidget/?contentId=<node page.id>",
  cache: false
}).done(function( html ) {
  $("#comments_<node page.id>").append(html);
});
</script>
<div id="comments_<node page.id>"></div>
#end##

2.7 How to use portal attributes for users in code


<?php
echo Yii::app()->user->email;
echo Yii::app()->user->firstname;
echo Yii::app()->user->lastname;
?>

2.8 Main layout for administration

There is one main layout page which is used by the portal administration functionality. For some administration functionality there are no widgets available, they use this main layout template which includes all CSS and JavaScript files.

Please see the example in the Demo CMS in the folder “Templates” named “main.php”.

All JavaScript and CSS files which must be included in the main layout template can be found on the Demo CMS in folder “Templates” / “CSS” / “Admin” and “Templates” / “JS” / “Admin”. They are obligatory.

You can use this template for your installation and adapt it to your design.

Link to see the main layout:“http://portaldemo.gentics.com/user/admin”

Do not use GetJS or GetCSS function of portal in this template!

Current example in portal:


<html>
<?php
Yii::app()->language = 'en';
Yii::app()->user->setState('language', 'en');
?>
<!DOCTYPE html>

<!--[if IE 7]>                  <html class="ie7 no-js" lang="en">     <![endif]-->
<!--[if lte IE 8]>              <html class="ie8 no-js" lang="en">     <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html class="not-ie no-js" lang="en">  <!--<![endif]-->

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-language" content="en" />  

<!-- moved the 2 libs up in DOM because portal inserts assets below css -->
<script src="/Content.Node/files/js/jquery-1.7.1.min.js"></script>

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

<title>Main Portal Template Gentics Portal.Node Demo</title>

<meta name="description" content=" Main Portal Template" />
<meta name="author" content="Node Admin" />

<!--[if !lte IE 6]><!-->
<?php if (isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS']!="on") { ?>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,300,800,700,400italic|PT+Serif:400,400italic" />
<?php } else { ?>
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,600,300,800,700,400italic|PT+Serif:400,400italic" />
<?php } ?>

<link rel="canonical" href="http://portaldemo.gentics.com/Content.Node/templates/main.php" />


<link rel="stylesheet" href="/Content.Node/files/css/jquery-ui.1.8.17.css" media="screen" />
<link rel="stylesheet" href="/Content.Node/files/css/styles.v5.css" media="screen,print" />
<link rel="stylesheet" href="/Content.Node/files/css/Media_Queries.en.css" media="screen" />
<link rel="stylesheet" href="/Content.Node/files/css/fancybox.min.css" media="screen" />
<!-- not necessary if you do not use the components -->



<link rel="stylesheet" href="/Content.Node/files/css/custom.portal.css" media="screen,print" />
<link rel="stylesheet" href="/Content.Node/files/css/print.css" media="print" />

<!--<![endif]-->

<!--[if lte IE 6]>
<link rel="stylesheet" href="/Content.Node/files/css/ie6.1.1.css" media="screen, projection">
<![endif]-->


<!-- HTML5 Shiv + detect touch events -->
<script src="/Content.Node/files/js/modernizr.custom.js"></script>

<?php if ( isset( $_GET['xoxo'] ) ) { ?>
<link rel="stylesheet" href="http://gt.myxoxo.at/xoxo-custom.css" media="screen, projection">
<?php } ?>

        <link rel="stylesheet" href="/Content.Node/files/css/admin/core.css" media="screen" />
        <link rel="stylesheet" href="/Content.Node/files/css/admin/default.css" media="screen" />
        <link rel="stylesheet" href="/Content.Node/files/css/admin/dhtmlxtree.css" media="screen" />
        <link rel="stylesheet" href="/Content.Node/files/css/admin/style.css" media="screen" />


<link rel="stylesheet" href="/Content.Node/files/css/admin/CSS_Admin.en.css" media="screen" />
<?php
Yii::app()->getModule('history')->save(Yii::app()->request->getHostInfo('').'/Content.Node/templates/main.php','Main Portal Template','3798');
?>


</head>

<body>

<!--noindexstart-->
<header id="header" class="container clearfix">

  <!--noindexstart-->
<!-- currently all portal modules are excluded from search indexing -->
<div class="metanav">
<span class="metanavlink">
<?php
if (Yii::app()->user->email == '') {
?>
<a class="metanavlink" href="/Content.Node/service/Registration.en.html">Register</a> | 
<a class="metanavlink" href="/Content.Node/service/Login.en.html">Login</a> | 
<?php
} else {

// frontend editing
if ( isset( $page ) && ( $page['template'] == '101' || $page['template'] == '103' || $page['template'] == '113' ) ) {
?>
<?php if ( ( isset( $_GET['edit'] ) && $_GET['edit'] != 'true' ) || !isset( $_GET['edit'] ) ) { ?>
<span style="float:left">
<a class="metanavlink feedit_buttons" href="?edit=true">
Edit
</a>&nbsp;|&nbsp;<a class="metanavlink feedit_buttons" href="?new=true">
New
</a>&nbsp;|&nbsp; 
</span>
<?php } ?>
<?php
}

echo Yii::app()->user->firstname . ' ' . Yii::app()->user->lastname . ' | ';
?>
<a class="metanavlink" href="/Content.Node/service/UserProfileEditWidget.en.html">Edit Profile</a> | 
<a class="metanavlink" href="/user/logout">Logout</a> | 
<?php
}
?>

<a class="metanavlink" href="/Content.Node/service/Search.en.html">Search</a> | 

</span>
</div>
<!--noindexend-->


  <nav id="main-nav">
  
    <!--noindexstart-->
<!-- currently all portal modules are excluded from search indexing -->
<?php 

/**
      $this->widget(
          'navigation.widgets.NavigationWidget',
          array('startfolderId'=>'10002.580',
                'cssClass'=>'',
                'maxLvl'=>1
          )
      );

**/

$this->widget(
      'navigation.widgets.NavigationWidget',
      array('startfolderId'=>'10002.580',
      'maxLvl'=>4, //or any other number moer than 1
      'isSitemap'=>true //important
      )
);

?>
<!--noindexend-->


  </nav><!-- end #main-nav -->
        
  <a href="/" id="logo">
    <img src="/Content.Node/img/gentics_logo.jpg" alt="Gentics" />
  </a>
  
</header><!-- end #header -->
<!--noindexend-->
        
<section id="content" class="container clearfix">

  <header class="page-header">

    <h1 class="page-title"><!--noindexstart-->
<!-- currently all portal modules are excluded from search indexing -->
<?php 

echo CHtml::encode($this->pageTitle);

?>
<!--noindexend-->
<!--node page.name:editable--></h1>

                <!--noindexstart-->
                
    <!--node gportal_breadcrumb-->
                <!--node gportal_admin_breadcrumb-->
    <!--noindexstart-->
<!-- currently all portal modules are excluded from search indexing -->
<?php 

$this->widget('zii.widgets.CMenu', array(
'itemCssClass' => 'breadcrumb',
                                               'items' => array(
                                                                array('url' => '/user/admin/', 'label' => Yii::app()->getModule('user')->t('Manage Users'), 'visible' => Yii::app()->user->checkAccess('Admin')),
                                                                array('url' => '/user/profileField/admin', 'label' => Yii::app()->getModule('user')->t('Manage Profile Fields'), 'visible' => Yii::app()->user->checkAccess('Admin')),
                                                                array('url' => '/user/admin/managePersonalisation/', 'label' => Yii::app()->getModule('user')->t('Personalisation Attributes'), 'visible' => Yii::app()->user->checkAccess('Admin')),
                                                                array('url' => '/user/assignment/view', 'label' => Yii::app()->getModule('user')->t('Assignments'), 'visible' => Yii::app()->user->checkAccess('Admin')),
                                                                array('url' => '/rights/assignment', 'label' => Yii::app()->getModule('user')->t('Rights'), 'visible' => Yii::app()->user->checkAccess('Admin')),
                                                                array('url' => '/settings/manage', 'label' => Yii::app()->getModule('user')->t('Settings'), 'visible' => Yii::app()->user->checkAccess('Admin')),
                                                                array('url' => '/bulk/bulk', 'label' => Yii::app()->getModule('user')->t('Bulk'), 'visible' => Yii::app()->user->checkAccess('Admin')),
                                                                /**array('url' => '/updates/release/create', 'label' => Yii::app()->getModule('user')->t('Create release'), 'visible' => Yii::app()->user->checkAccess('Admin')),
                                                                array('url' => '/updates/release/updateStep1', 'label' => Yii::app()->getModule('user')->t('Update'), 'visible' => Yii::app()->user->checkAccess('Admin')),**/
                                                                ),
                                               )); 

/**

                                                                array('url' => Yii::app()->getModule('user')->loginUrl, 'label' => Yii::app()->getModule('user')->t("Login"), 'visible' => Yii::app()->user->isGuest),
                                                                array('url' => Yii::app()->getModule('user')->registrationUrl, 'label' => Yii::app()->getModule('user')->t("Register"), 'visible' => Yii::app()->user->isGuest),
                                                                array('url' => Yii::app()->getModule('user')->profileUrl, 'label' => Yii::app()->getModule('user')->t("Profile"), 'visible' => !Yii::app()->user->isGuest),
                                                                array('url' => Yii::app()->getModule('user')->logoutUrl, 'label' => Yii::app()->getModule('user')->t("Logout") . ' (' . Yii::app()->user->name . ')', 'visible' => !Yii::app()->user->isGuest),
**/

?>
<!--noindexend-->

    <!--noindexend-->
                
        </header><!-- end .page-header -->
    
      <div>

        <!--noindexstart-->
<!-- currently all portal modules are excluded from search indexing -->
<?php 

echo $content;

?>
<!--noindexend-->

        
      </div>
        
</section><!-- end #content -->
    
<!--noindexstart-->
                
<footer id="footer" class="clearfix">
  <div class="container">
    <div class="three-fourth">
      <nav id="footer-nav" class="clearfix">
        <ul>
        <li><a href="http://www.gentics.com" target="_blank">Gentics Software GmbH</a></li>
        </ul>
        <!--node gportal_sitemap-->
      </nav><!-- end #footer-nav -->

      <ul class="contact-info">
        <li class="address"><a href="https://maps.google.com/maps?q=gentics&hl=en&ll=48.214965,16.370659&spn=0.007978,0.01929&sll=37.0625,-95.677068&sspn=38.775203,79.013672&hq=gentics&radius=15000&t=m&z=16" target="_blank">Gonzagagasse 11/25, A-1010 Vienna/Austria</a></li>
        <li class="phone"><a href="call:+43171099040">+43171099040</a></li>
        <li class="email"><a href="mailto:demo@gentics.com">demo@gentics.com</a></li>
      </ul><!-- end .contact-info -->
      
    </div><!-- end .three-fourth -->
    <div class="one-fourth last">
      <span class="title">STAY CONNECTED</span>
            <ul class="social-links">
                <li class="twitter"><a href="http://twitter.com/gentics" target="_blank">Twitter</a></li>
                <li class="facebook"><a href="http://facebook.com/gentics.cms" target="_blank">Facebook</a></li>
        <li class="digg"><a href="http://digg.com/search?submit=&q=%22gentics%22+cms" target="_blank">Digg</a></li>
        <li class="vimeo"><a href="http://vimeo.com/user1446715" target="_blank">Vimeo</a></li>
        <li class="youtube"><a href="http://www.youtube.com/user/genticsvideos" target="_blank">YouTube</a></li>
                <li class="skype"><a href="call://cqeb--">Skype</a></li>
      </ul><!-- end .social-links -->

    </div><!-- end .one-fourth.last -->
  </div><!-- end .container -->
</footer><!-- end #footer -->

<footer id="footer-bottom" class="clearfix">
  <div class="container">
    <ul>
      <li>&copy; by Gentics Software GmbH</li>
    </ul>
  </div><!-- end .container -->
</footer><!-- end #footer-bottom -->

<script src="/Content.Node/files/js/jquery-ui-1.8.23.custom.min.js"></script>
<script src="/Content.Node/files/js/jquery-ui-i18n.min.js"></script>

  <!--[if lt IE 9]> <script src="/Content.Node/files/js/selectivizr-and-extra-selectors.min.js"></script> <![endif]-->

  <script src="/Content.Node/files/js/respond1.min.js"></script>
  <script src="/Content.Node/files/js/jquery.easing-1.3.min.js"></script>
  <script src="/Content.Node/files/js/jquery.fancybox.min.js"></script>
  <script src="/Content.Node/files/js/jquery.jcarousel.min.js"></script>
  <script src="/Content.Node/files/js/jquery.cycle.all.min.js"></script>
  <script src="/Content.Node/files/js/jquery.touchSwipe.min.js"></script>
  <script src="/Content.Node/files/js/jquery.json.min.js"></script>
  <script src="/Content.Node/files/js/jquery.yiiactiveform.js"></script>
  <!--script src="/Content.Node/files/js/archive/custom.js"></script-->
  <script src="/Content.Node/files/js/custom.portal.js"></script>





<!--<![endif]-->

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-32880019-1']);
  _gaq.push(['_setDomainName', '<?php echo $_SERVER['HTTP_HOST']; ?>']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
<!-- Piwik --> 
<script type="text/javascript">
  var pkBaseURL = (("https:" == document.location.protocol) ? "/piwik/" : "/piwik/");
  document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
  var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 2);
  piwikTracker.trackPageView();
  piwikTracker.enableLinkTracking();
} catch( err ) {}
</script>
<noscript><p><img src="/piwik/piwik.php?idsite=2" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->


        <script src="/Content.Node/files/js/admin/dhtmlTreeEditor.js"></script>
        <script src="/Content.Node/files/js/admin/dhtmlTreeUserAssignment.js"></script>
        <script src="/Content.Node/files/js/admin/dhtmlxcommon.js"></script>
        <script src="/Content.Node/files/js/admin/dhtmlxtree.js"></script>
        <script src="/Content.Node/files/js/admin/dhtmlxtree_json.js"></script>
        <script src="/Content.Node/files/js/admin/dhtmlxtree_xw.js"></script>
        <script src="/Content.Node/files/js/admin/jquery.ba-bbq.min.js"></script>
        <script src="/Content.Node/files/js/admin/jquery.yii.js"></script>
        <script src="/Content.Node/files/js/admin/jquery.yiigridview.js"></script>
        <script src="/Content.Node/files/js/admin/rights.js"></script>



<!--noindexend-->

</body>