Include Core CSS in one particular file in YII - php

I disabled core css file because it was intercepting with my custom css files:
$cs = Yii::app()->getClientScript();
$cs->scriptMap = array(
'*.css' => false,
);
Now, I need core css files in one view only.
Is there anyway to include those core css files in one view?

You can do it like this
In config/main.php under components section
'clientScript'=>array(
'packages'=>array(
'CoreCss'=>array(
'baseUrl'=> 'css/' ,
'css'=>array('main.css','ie.css','form.css','screen.css','print.css'),
),
),
In any page you want to register this css use below lines..
$cs = Yii::app()->clientScript;
$cs->registerPackage('CoreCss');
may be this things can help you...

Related

Does Bootstrap CSS override theme?

Over the past few years, I have worked with many WordPress theme templates. I have now decided to take the next step of learning to create my own WordPress themes.
I am now at the stage whereby I am looking to use the Bootstrap feature, in order to make my website responsive. I understand how to transfer files from the Bootstrap website and place them on my server, however I am at a loss on how they work with my website. Here area few questions:
I have already created a '[theme-name].css' to style my website. Will the Bootstrap CSS file automatically override my theme CSS file (s)?
When I transfer the Bootstrap files to my server, do I simply add the contents of my own stylesheet, the Bootstrap CSS file or call both CSS files together using the 'function.php' file?
When I transfer the Bootstrap files to my server, do I have to rename any of the files?
At present, I am currently calling my stylesheets, by inserting the following code in my 'functions.php' file:
function [theme-name]_script_enqueue() {
wp_enqueue_style('customstyle', get_template_directory_uri() . '/css/[theme-name].css', array(), '1.0', 'all');
wp_enqueue_script('customjs', get_template_directory_uri() . '/js/[theme-name].js', array(), '1.0', true);
}
add_action( 'wp_enqueue_scripts', '[theme-name]script_enqueue' );
Referring to the above code, would I need to change the code to reflect the Bootstrap.css files or simply add another function for the Bootstrap files, so that they can both be called?
Apologies if my questions are using incorrect terminologies, as the Bootstrap functionality is a new set of files to me.
You should be able to just add another call to load the bootstrap css. Make sure you add bootstrap before your custom CSS.
See below
https://bootstrapbay.com/blog/customize-bootstrap/
You shouldnt need to rename any files providing you link them correctly in your function call.

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

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.

Drupal 7: Reorder the css files

I have included the following css files into my_theme.info file
stylesheets[all][] = style.css
stylesheets[all][] = css/all.css
stylesheets[all][] = css/static.css
and this files are loading on every page, but my particular css file associated with page is loading before the above css files.
But i want above css files should load first then my page css file load
what i do for that?
By default css files of theme (as set in mytheme.info file) are loading very last and after any other css files of any module. This is done to override any css if needed.
So, if you want to load the css files before any other you should better add them with drupal_add_css function in a custom module and set their weight as -100 or less (number is just an example of order weight).
To get the path you can use the current_path() or drupal_get_path_alias() (for the alias) or any other function/method to get the path.
But, as you said, these are theme css files so in your custom module you could also write this in your module:
function mymodule_init() {
// Set theme's path
$themepath = drupal_get_path('theme', 'mytheme');
// check current path
if (current_path() == "internal/path/of/the/page") {
// add theme css in group CSS_SYSTEM
drupal_add_css($themepath . '/path/to/mycss.css', array('group' => CSS_SYSTEM, 'type' => 'file', 'weight' => -100));
}
}
The code above will move the mycss.css file to group "CSS_SYSTEM" that loads the core css files first and before any other css files from modules (CSS_DEFAULT) or theme (CSS_THEME)

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