Button for creating custom pages or Macros


The idea is to create a page creation button that pre-parameters the page creation wizard, so that with one click the user can create a new news item using the "G" template and the "News" content type with the "Headlines" label.

A button is declared in a plugin.xml file. If you need to create a new plugin, follow the instructions on the plugin Ametys page.

Here are the settings for the default page creation button declared in plugin web.

	 <!-- +
    	 | SITEMAP
    	 + -->
     <feature name="userinterface.sitemap.create">
		<extensions>
    		<!-- Ajouter une page -->
    		<extension id="org.ametys.web.userinterface.AddPage"
					   point="org.ametys.cms.workspace.ribbon.RibbonControlsManager" 
					   class="org.ametys.runtime.ui.impl.StaticContextualClientSideElement">
				<action class="org.ametys.ribbon.control.button.SitemapOrModifiablePageActionButton">
					<param name="action">org.ametys.web.tool.page.Add.act</param>
					<param name="label" i18n="true">PLUGINS_WEB_UITOOL_ADDPAGE_LABEL</param>
					<param name="default-description" i18n="true">PLUGINS_WEB_UITOOL_ADDPAGE_DESC</param>
					<param name="no-right-description" i18n="true">PLUGINS_WEB_UITOOL_PAGE_NORIGHT_DESC</param>
					<param name="no-selection-description" i18n="true">PLUGINS_WEB_UITOOL_PAGE_NOSELECTION_DESC</param>
					<param name="footer" i18n="true">PLUGINS_WEB_UITOOL_ADDPAGE_FOOTER</param>
					<param name="icon-small" file="true">img/actions/page_add_16.png</param>
					<param name="icon-medium" file="true">img/actions/page_add_32.png</param>
					<param name="icon-large" file="true">img/actions/page_add_50.png</param>
				</action>
				<scripts>
					<file>js/org/ametys/web/tool/page/Actions.i18n.js</file>
                    <file>js/org/ametys/web/tool/page/AddPageWizzard-TagsCard.i18n.js</file>
                    <file>js/org/ametys/web/tool/page/AddPageWizzard-PageTypeCard.i18n.js</file>
                    <file>js/org/ametys/web/tool/page/AddPageWizzard-PageContentCard.i18n.js</file>
                    <file>js/org/ametys/web/tool/page/AddPageWizzard-CreatePageCard.i18n.js</file>
                    <file>js/org/ametys/web/tool/page/AddPageWizzard-Cards.i18n.js</file>
					<file>js/org/ametys/web/tool/page/AddPageWizzard.i18n.js</file>
					<file>js/org/ametys/ribbon/control/button/SitemapOrModifiablePageActionButton.js</file>
					<file>js/org/ametys/web/page/TemplatesMenu.i18n.js</file>	
					<file>js/org/ametys/web/page/LinkPage.i18n.js</file>		
					<file>js/org/ametys/web/zone/AddContentAction.i18n.js</file>
					<file>js/org/ametys/web/zone/AddServiceAction.i18n.js</file>
				</scripts>
				<css>
					<file>css/pages/addpage.css</file>
				</css>
				<right>Web_Rights_Page_Create</right>
			</extension>
		</extensions>     
     </feature>

Declare your own button (by modifying the identifier, images, keys i18n) and adding the following parameters:

  • title: Dialog box title
  • icon-small: Dialog box icon
  • default-page-title: Default title for the new page
  • default-pagetype: default page type (template, redirect-cms, redirect-http or blank)
  • default-template: Template selected by default
  • default-pagecontent-type: default element type (contenttype or service)
  • default-contenttype: Default content type
  • default-service: Default service type
  • default-tags: Default tags in the format: 'IDENTIFIER1':'TYPE1', 'IDENTIFIER2':'TYPE2'. Where the type is 'CONTENT' or 'PAGE'. For example 'FOOTER_LINKS': 'PAGE', 'SPECIAL_PAGES': 'PAGE', 'A_LA_UNE': 'CONTENT'.
  • force: if "true", the setup wizard will be automatically validated.

Warning
It is your responsibility if you use macro mode (force=true) to check that all rights are correct.
For example, if you force the creation of a news item, you must add verification of the news creation right, otherwise the macro will automatically choose another type of authorized content.

Finally, reference your button in the ribbon file(instructions).

Example

Here's an example of a news button labeled "Special pages".

      <feature name="mymacro">
        <extensions>
            <!-- Ajouter une page -->
            <extension id="mymacro.addNews"
                       point="org.ametys.cms.workspace.ribbon.RibbonControlsManager" 
                       class="org.ametys.runtime.ui.impl.StaticContextualClientSideElement">
                <action class="org.ametys.ribbon.control.button.SitemapOrModifiablePageActionButton">
                    <param name="action">org.ametys.web.tool.page.Add.act</param>
                    <param name="label" i18n="false">Nouvelle actualité spéciale</param>
                    <param name="default-description" i18n="false">Ce bouton permet de créer une nouvelle page doté du gabarit 'Page', d'une actualité et étiquetté 'Pages spéciales'</param>
                    <param name="no-right-description" i18n="false">Vous n'avez pas le droit de créer une actualité ici</param>
                    <param name="no-selection-description" i18n="false">Sélectionnez une page pour pouvoir créer une actualité</param>
                    <param name="footer" i18n="false">Consultez l'aide pour plus d'information</param>
                    <param name="icon-small" file="true" plugin="news">img/news_16.png</param>
                    <param name="icon-medium" file="true" plugin="news">img/news_32.png</param>
                    <param name="icon-large" file="true" plugin="news">img/news_48.png</param>
                    
                    <param name="title">Ajouter une actualité spéciale...</param>
                    <param name="default-page-title">Nouvelle actualité spéciale</param>
                    <param name="default-pagetype">template</param>
                    <param name="default-template">page</param>
                    <param name="default-pagecontent-type">contenttype</param>
                    <param name="default-contenttype">org.ametys.web.default.Content.news</param>
                    <param name="default-tags">'SPECIAL_PAGES': 'PAGE'</param>
                    
                    <param name="force">true</param>
                </action>
                <scripts>
                    <file plugin="web">js/org/ametys/web/tool/page/Actions.i18n.js</file>
                    <file plugin="web">js/org/ametys/web/tool/page/AddPageWizzard-TagsCard.i18n.js</file>
                    <file plugin="web">js/org/ametys/web/tool/page/AddPageWizzard-PageTypeCard.i18n.js</file>
                    <file plugin="web">js/org/ametys/web/tool/page/AddPageWizzard-PageContentCard.i18n.js</file>
                    <file plugin="web">js/org/ametys/web/tool/page/AddPageWizzard-CreatePageCard.i18n.js</file>
                    <file plugin="web">js/org/ametys/web/tool/page/AddPageWizzard-Cards.i18n.js</file>
                    <file plugin="web">js/org/ametys/web/tool/page/AddPageWizzard.i18n.js</file>
                    <file plugin="web">js/org/ametys/ribbon/control/button/SitemapOrModifiablePageActionButton.js</file>
                    <file plugin="web">js/org/ametys/web/page/TemplatesMenu.i18n.js</file>   
                    <file plugin="web">js/org/ametys/web/page/LinkPage.i18n.js</file>        
                    <file plugin="web">js/org/ametys/web/zone/AddContentAction.i18n.js</file>
                    <file plugin="web">js/org/ametys/web/zone/AddServiceAction.i18n.js</file>
                </scripts>
                <css>
                    <file>css/pages/addpage.css</file>
                </css>
                <rights mode="AND">
                    <right>Web_Rights_Page_Create</right>
                    <right>Web_Rights_Page_Templates</right>
                    <right>Web_Rights_Page_AddContent</right>
                    <right>News_Right_News_Create</right>
                    <right>Web_Rights_Page_Tag</right>
                </rights>
            </extension>
        </extensions>     
     </feature>    

puis dans cms-ribbon-default.xml j'ajoute après chaque apparition de "<control id="org.ametys.web.userinterface.AddPage"/>" :

<control id="mymacro.addNews"/>

Any change to plugin.xml requires a restart of the cms

Back to top