Diffrent settings in module.config.php for every module in zf2 - php

I have got two modules: admin and application in first have:
'view_helper_config' => array(
'flashmessenger' => array(
'message_open_format' => '<div%s><button data-dismiss="alert" class="close" type="button">×</button>',
'message_separator_string' => '<br>',
'message_close_string' => '</div>'
),
),
in second have:
'view_helper_config' => array(
'flashmessenger' => array(
'message_open_format' => '<ul%s><li>',
'message_separator_string' => '<li></li>',
'message_close_string' => '</li></ul>'
),
),
and it's always merged. I would like to have on every module diffrent config. How can I do it?

Keep in mind that your module.config.php files act a bit like cascading style sheets in that the first one gets loaded and then the settings in the subsequent files either supplement or replace the settings that were loaded by the previous files. The module.config.php files get loaded in the order that the modules are listed in project\config\application.config. In other words, the statements that you have included in two different files are equivalent to listing them one after another in the same module.config.php.
There are several solutions to your question:
Clone the helper by extending it and giving it a different name, and use different versions in different modules. (If you do this you
might even be able to set the default HTML strings in the aliases
and avoid setting them in module.config.php altogether).
Set the HTML strings in your views rather than in module.config.php. Look at the documentation to learn how.
Clone your layout.phtml and set the strings in there. The solution above requires that you set the HTML strings in each and
every view that you create, but the documentation says you can set
them in any .phtml. EdpModuleLayouts allows you to have
separate, module-specific layouts; and you can create a different
layout for each module and set your chosen HTML strings in each
layout.
Toggle HTML strings on and off with CSS classes. I use EdpModuleLayouts so that the skin for my admin module is strikingly
different from the other module(s), and so I already have alternate
CSS files for different modules. With these, it is possible to
toggle HTML strings on and off. For your application you could put
a class=”toggleFM” in relevant tags and set the CSS settings to
display: hidden; accordingly so that in one module certain
elements are rendered and in another module other elements are
rendered. This is a convoluted solution, but it allows you to set
the HTML strings in your module.config.php files if that’s what you
want to do.
EDIT
Also, take a look at your separator string. You probably want '</li><li>' and not '<li></li>' because the separator closes a list item and opens another.

Related

Using FlexForm when creating new content cType in TYPO3 plugins

I'm adding new content types to my TYPO3 and I want to use FlexForms to define each content type options form.
I have followed this example: https://docs.typo3.org/typo3cms/extensions/fluid_styled_content/latest/AddingYourOwnContentElements/
And modified it to use FlexForms from this example: https://wiki.typo3.org/Extension_Development,_using_Flexforms
But I believe I don't quite understand the settings in Configuration/TCA/Overrrides/tt_contant.php:
// Adds content new content elements
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(
[
'LLL:EXT:lu_content/Resources/Private/Language/locallang.xlf:contacts.title',
'lu_content__contacts',
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('lu_content').'Resources/Public/Icons/Contacts.svg',
],
'CType',
'lu_content'
);
$GLOBALS['TCA']['tt_content']['types']['lu_content__contacts']['showitem'] = 'CType;;;1-1-1,pi_flexform;;;1-1-1';
$GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds'][',lu_content__contacts'] = 'FILE:EXT:lu_content/Configuration/FlexForms/Contacts.xml';
The form works, but looks like this:
How do I get the form not to fall under Plugin Options?
And how do I make the title/header to be used in to list view? Currently i get [notitle] after save in the content list.
Thank you in advance.
PS: I'm currently developing on TYPO3 v7 but with support for v8.
The Text for the tab as well as the arrangement of any tabs and fields is defined for general plugins in
$GLOBALS['TCA']['tt_content']['types']['list']
If you have defined an own CType it's quite probable that you wish to define own fields, palettes and types, hide standard-fields and perhaps replace default labels.
The whole configuration for tt_content is quite complicated as it is used for all different content-elements and it can be seen in backend below System -> Configuration -> GLOBALS[TCA]:
The simplest option is to replace the label for the tab in $GLOBALS['TCA']['tt_content']['types']['list'].
Before / Default:
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,--palette--;;general,--palette--;;headers,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.plugin,list_type;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:list_type_formlabel,pages;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:pages.ALT.list_formlabel,recursive,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,--palette--;;frames,--palette--;;appearanceLinks,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,--palette--;;language,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,--palette--;;hidden,--palette--;;access,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,--div--;LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_category.tabs.category,categories,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,rowDescription,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended
After / location to fill with own label: (look for ###YOUR_LABEL###):
--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,--palette--;;general,--palette--;;headers,--div--;###YOUR_LABEL###,list_type;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:list_type_formlabel,pages;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:pages.ALT.list_formlabel,recursive,--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,--palette--;;frames,--palette--;;appearanceLinks,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,--palette--;;language,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,--palette--;;hidden,--palette--;;access,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,--div--;LLL:EXT:lang/Resources/Private/Language/locallang_tca.xlf:sys_category.tabs.category,categories,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,rowDescription,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended
and a more difficult approach would be to define an own type in $GLOBALS['TCA']['tt_content']['types'].
Here you find The documentation about TCA.
For your case are especially interesting the following chapters:
Pallets
Types
Interface
But if you want to change labels or other configuration of single fields you'd had to refer to the chapter / configuration about columns.
In the area ctrl you still can define some general options like sorting-fields or the behavior when the whole element is copied, have a look in that chapter to get an impression about all options. Also the desired and default label and value-field is configured there with
$GLOBALS['TCA']['tt_content']['ctrl']['label']
its also possible to combine two or more fields for the default display:
$GLOBALS['TCA']['tt_content']['ctrl']['label'] = 'header';
$GLOBALS['TCA']['tt_content']['ctrl']['label_alt'] = 'subheader';
you might still want to add the option
$GLOBALS['TCA']['tt_content']['ctrl']['label_alt_force'] = 1;
Configuring the form for a plugin can take quite some time even to understand all the options, but in general there are very much options to individualize it related to many needs. It's even possible to define user-functions to handle and display own options in the form which are not covered by the existing options.

Preventing a specific CSS file from getting loaded in Yii

I am coding in Yii.
I have registered the main.css file in my main.php layout file like so :
Yii::app()->clientScript->registerCssFile($this->assetsBase.'/css/main.css');
Now this script is being registered in all the pages. However, say I don't want that script to be registered on a specific page.
I know that using :
Yii::app()->clientScript->reset();
would remove all the CSS files, however I want only few CSS files to be unregistered.
Is there a way to do it?
You can use the scriptMap property of CClientScript in your specific view, passing false for the particular script/css file's key that you don't want to be rendered. From the doc:
The array keys are script file names (without directory part) and the array values are the corresponding URLs. If an array value is false, the corresponding script file will not be rendered.
For example, in say views/site/pages/about.php:
Yii::app()->clientScript->scriptMap = array(
'main.css' => false
);
to disable the inclusion of main.css registered with registerCssFile.
The scriptMap can also be used for controlling the rendering of js script files.
I would suggest either:
Using a separate layout for that page like main_no-css.php
or
Adding a condition before registering the script (like if controller != xxx and action != yyy), but this would cause the condition to be checked on every other page.
I would definitely go for a separate layout.

How to make a template overwrite for mod_menu with alternative layouts for link outputs?

I understand and love template overwrites. I need to do some heavier changes to the menu output (basically making the output work better with Bootstrap) - but only for certain menus.
Currently in Joomla 3 there are the following in the mod_menu/tmpl folder:
default.php
default_component.php
default_heading.php
default_separator.php
default_url.php
If I want to change the classes I'd copy the default.php into my mytemplate/html/mod_menu and change it. Great, no problem.
If I want to change the link outputs to go along with that I can copy the default_component.php to mytemplate/html/mod_menu and change it. Great, no problem.
If I want to have the choice of having a different "Alternative Layout" I'd rename the mytemplate/html/mod_menu/default.php to newlayout.php, then select it in the admin module manager for that menu. Great, no problem.
Here's the problem: If I want to have the link output changed for certain menus but not all of them I figure I'd change default_component.php to newlayout_component.php like I did above which would correspond to the newlayout.php...but that doesn't work.
Questions:
1) How to have alternative layouts for each of the default_component.php, default_heading.php, default_separator.php, default_url.php template files (not just an overwrite)?
2) I would think default_url.php is the one that would affect the link outputs but it seems it's default_component.php that does. So what does each one of those do? I couldn't find any information on joomla.org about that.
Thanks!
The alternative layout feature only works for the main file (default.php), not for the sublayouts (default_component.php, ...). So you have to create your own newlayout.php which then can load newlayout_component.php, or use the default_component.php. In fact, the default_component.php will be used as fallback if no newlayout_component.php is found.
The code switches over the $item->type of the link. 'separator', 'url', 'component' and 'heading' are handled by the 'default_'.$item->type, everything else will use default_url. So a plain URL should indeed be generated by default_url.php, not default_component.php. If it behaves differently, it's likely a bug.

opencart - How to manually display a module inside a template file?

Let's say I want to display the specials module on the homepage in a position different than $content_top, $content_bottom, $column_left or $column_right. How do I do that? If you have some experience with this, could you give me some pointers?
The module will be display in home.tpl but I'm assuming I would need to edit the controller file home.php
To do this, you will need to make edits to two files
Firstly, you will need to edit the controller. In this example, I'm going to add the specials to the home page
So open the controller file catalog/controller/common/home.php. Somewhere before this line $this->response->setOutput($this->render()); add the following
$this->data['special_block'] = $module = $this->getChild('module/special', array(
'limit' => 5,
'image_width' => 80,
'image_height' => 80
));
The array is the settings for the module. Note that the layout, position, status and sort order aren't included, as they're irrelevant here. I've also used special_block as a unique key for the content, to avoid it conflicting with any other items that may need rendering
Then in your template file, you just need to use <?php echo $special_block; ?> wherever you want the module to go

ViewScript decorator unable to set

I am following the section about "Full Customization Using the ViewScript Decorator" from this page -> http://devzone.zend.com/article/3450
In the init method of my form class I have added this
$this->setDecorators(
array(
array(
'ViewScript',
array(
'script' => 'display.phtml'
)
)
)
);
Now in the place where my form appeared I have this:
An error occurred
Application error
What am I doing wrong here? I really need to customize the appearance of the form and I just want to change the form and not the appearance of the whole page.
I have tried this:
$this->setElementDecorators(array(array('ViewScript', array('viewScript'=>'display.phtml'))))
Which works but affects the display of the whole page (I am using zend layout). I just need the render of the form to be passed to the display.phtml page.
Note: Is there any place in particular I have to place the display.phtml? I placed it in the view\scripts folder.
I think it is as simple as this.
The ViewScript cannot be used in the init() method for your form for one simple reason. If you look at the example (and probably your display.phtml) there are echo statements like this one $this->form->firstname;. At this point in init() the form elements are not loaded yet!
The author therefore correctly shows this code
$form->setDecorators(array(
array('ViewScript', array('script' => 'demogForm.phtml'))
));
Note that he uses $form as the object. Either in controller or view script you load your form as an object and then add the ViewScript. So in one of your controllers you would do something like this
$form = new My_Form();
$scriptPath = '/path/to/script/display.pthml'
// or without a path if you have a script folder loaded
$form->setDecorators(array(
array('ViewScript', array('script' => $scriptPath))
));
This should do the trick.
Update Looking at the naming of your pthml I assume (and hope) this is a special template for your form and not your whole layout file. If you use your whole layout file then of course if will render the whole page!
When working with view scripts, I find it's best to make any such changes at the view level.
Ignore the "ViewScript" decorator details in your form and set them from the view, eg
<?php echo $this->form->setDecorators(array(
'PrepareElements',
array('ViewScript', array('viewScript' => '_forms/display.phtml'))
)) ?>
The location of the display.phtml file is relative to the module's view scripts folder. If this is just the default module (under the application folder), the script in my example will be located at application/views/scripts/_forms/display.phtml
If you want to remove HTML tags like <dt> or <dd> (labels and viewscript) you can use methods removeDecorator('HtmlTag') or removeDecorator('Label')

Categories