Skip to content

Latest commit

 

History

History
156 lines (125 loc) · 9.08 KB

README.md

File metadata and controls

156 lines (125 loc) · 9.08 KB

Yii2-simple-cms

A basic yii2 content management module for easily creating and maintaining a page structure, including navigation widget, full text search, image and document management and a wysiwyg html editor for the content pages. Does not include an fine granulated access rights management, only differentiates between: anonymous/guest and logged in users. The extensions supports site structures in multiple languages for international sites.

NOTE: Module is in initial development. Anything may change at any time.

Documentation

Yii2-simple-cms documentation is available online:

See Project page for source code and Project wiki for more details, screenshots etc.

Installation instructions are located in the installation guide

Prefered way is using composer by adding the reuquirement to your composer.json and running composer update afterwards:

"require": {
    "schallschlucker/yii2-simple-cms": ">=0.2.4",
}

After installation run migration for database table creation (it is assumed at this point, that the yii2 db module is configured properly in your configuration). Currently the scripts support only mysql databases, other databases might work as well but haven't been tested yet and thus are disabled in the migration script):

yii migrate --migrationPath=@schallschlucker/simplecms/migrations

Finally create a folder where to store the uploaded images from the WYSIWYG editor. To do so, create a subfolder named "mediarepository" in the web folder of you application. If you use separated applications for backend and frontend, simply create a simlink to the sceond web folder to use the mediarepository there as well. Then set the access rights to this folder accordingly so that php is allowed to write to this folder.

It is also possible to place the mediarepository outside of the web folder to limit access to uploaded files, but then each file needs to be read by php and delivered to the client which certainly has an impact on the performance, so this should only be used if the media data is somewhat sensitive and should only be availbale to logged in users. when the folder is not placed in the web folder, the module configuration needs to be changed (at the moment you need to edit the backend.php and frontend.php file in the vendor folder of simple-cms, in future versions we will document how to overwrite the path in the module configuration)

#Usage

the extension is split into two modules: the frontend and the backend module.

Frontend provides the needed controllers to: - display page content - display documents - display a search form and a search result page Widgets to: - render a navigation menu (extending yii\bootstrap\Nav widget) - render the navigation structure in different formats like a html list (ol or ul and li nodes), xml, json - render the search bar - render extended search form - render the search results list

The backend provides administrative functions for maintaining the page tree structure (including drag and drop functionality, keyboard shortcuts and context menus for easy creation of new pages).

Both modules can be deployed in the same application, but it is recommended to follow the frontend/backend approach to clearly separate the frontend (user view) from the administrative backend interface.

Content pages in simple cms can be created in multiple language, since simple cms uses internal language id's which might differ from your applications language codes (i.e. ISO 2 letter code or 5 letter code) you need ti initalize the LanguageManager in the components section with a valid mapping to map you applications language codes to the simple cms language codes. Here is an example (which also uses aliases to e.g. map the application language code "de-DE" to the simple cms language code "1" etc.). You can add support for additional languages in simple cms just by adding new mappings.:

'components' => [
	'simplecmsLanguageManager' => [
    	'class' => 'schallschlucker\simplecms\LanguageManager',
    	'languageIdMappings' => [
            '1' => [
			    'id' => 1,
                	'code' => 'de_DE', 
	                'displaytext' => [
    	                'de_DE' => 'deutsch', 
        	            'en_US' => 'german',
            	        'pl_PL' => 'niemiecki',
                	    'tr_TR' => 'alman',
	                ],
    	        ],
                'de_DE' => [
                    'alias' => '1'
                ],
                'de-DE' => [
                	'alias' => '1'
	            ],
    	        '2' => [
        	        'id' => 2,
			        'code' => 'en_US', 
            	    'displaytext' => [
                	   	'de_DE' => 'englisch', 
                    	'en_US' => 'english',
	                    'pl_PL' => 'angielski',
    	                'tr_TR' => 'ingilizce',
        	        ],
            	],
                'en_US' => [
                    'alias' => '2',
                ],
                'en-US' => [
    	            'alias' => '2',
        	    ],
            	'3' => [
					'id' => 3,
                	'code' => 'pl_PL', 
	                'displaytext' => [
    	                'de_DE' => 'polnisch', 
        	            'en_US' => 'polish',
            	        'pl_PL' => 'polski',
                	    'tr_TR' => 'lehçe',
	                ],
    	        ],
        	    '4' => [
            	    'id' => 4,
					'code' => 'tr_TR', 
                	'displaytext' => [
                    	'de_DE' => 'türkisch', 
	                    'en_US' => 'turkish',
    	                'pl_PL' => 'turecki',
        	            'tr_TR' => 'türk',
            	    ],
            	],
    	],
],
'modules' => [
	'simplecms_backend' => [
        'class' => 'schallschlucker\simplecms\Backend',
		'languageManager' => 'simplecmsLanguageManager',
		'cache' => 'cache',
        ],
	'simplecms_frontend' => [
		'urlPrefix' => 'cms', //the context alias for the module if you do not want to use simplecms_frotend in your URLs to call the pretty URL aliases
        'class' => 'schallschlucker\simplecms\Frontend',
		'languageManager' => simplecmsLanguageManager,
		'renderTopMenuNavbar' => true, //boolean to indicate if a bootstrap navbar dropdown navigation (using CmsBootstrapNavbarWidget) should be rendered by the view. Set to false of you build your own navigation using one of the widgets provided by simplecms (e.g. CmsBootstrapNavbarWidget or CmsSitemapWidget)  (optional, default is true)
		'htmlTitlePrefix' => '', //string to prepend to html title tag (optional, default is empty)
		'htmlTitleSuffix' => '', //string to append to generated html title tag (optional, default is empt)
		'cache' => 'cache' //NOTE: remove this line if you do not have a cache component configured. Caching will reduce the load on the server a lot when building page trees, so it is highly recommended to user a proper cache implementation like memcached etc.
    ],
    'media_manager' => [
        'class' => 'schallschlucker\simplecms\MediaManager',
        'mediarepositoryPath' => '/var/www/virtualhosts/www.einzelpflegefachkraft.de/curassist-app/mediarepository/',
    ],
],

After the modules are registered, you should be able to open the administration backend by calling the "simplecms_backend" route e.g. by calling:

http://yourserver/index.php?r=simplecms_backend

or if pretty URLs are activated:

http://yourserver/simplecms_backend

Then you should see the Simple CMS Administration Backend with a root node in the page-tree. By right-clicking on the root node you can add new pages to the page tree. Each page has multiple language versions, so you can create common page tree structure for all different language versions. Via drag and drop you can rearange the positions of the pages within the page tree. Each page (except for the root node) can be set to one of three states:

  • visible: it will show up in the rendered navigation by the navigation widget
  • hidden: the page won't be shown in the navigation, yet it can be linked of found in the search
  • unpublished: the page will neither be shown in the navigation nor in the search results and cannot be linked

Each page can have three different behavious/types:

  • content page: the page is a normal content whose content can be edited via the embeded WYSIWYG editor
  • linked document: the page is basically a link to a uploaded document (e.g. PDF) that will be rendered as a link in the navigation
  • URL: the page will directly link to any given URL. This can be used to create an alias of a page in the navigation or to link to an external URL and embedding this link in the normal navigation

You can select one of these page types when creating a new page language version.

Please note:

In order for the page administration to work you need to be logged in, otherwise an error will occur since the user id will be stored for auditing purposes upon page creation or modification.

License

yii2-simple-cms is released under the Apache License 2.0. See the bundled LICENSE.md for details.