OpenCart 2.x Change default view to list-view - opencart2.x

I would like to permanently set the default view in OpenCart 2.1.0.2 to list-view instead of grid-view. I do not want to give my visitors ability to switch to grid-view; hence I'd like to completely disable grid-view and keep only list-view. Any assistance would be greatly appreciated.

You can do that using two methods for default list view.
1st method: replace following code (catalog/view/javascript/common.js)
if (localStorage.getItem('display') == 'list') {
$('#list-view').trigger('click');
} else {
$('#grid-view').trigger('click');
}
and using the following code in place
if (localStorage.getItem('display') == 'grid') {
$('#grid-view').trigger('click');
} else {
$('#list-view').trigger('click');
}
2nd method: If you don't want/like to permanently remove grid view then remove the code in (catalog/view/javascript/common.js) and make following code in common.js only
$('#grid-view').trigger('click');

Related

How to override template file item-list.html.twig for field_slider_images in Drupal 8?

I want to override the item listing template file core/themes/classy/templates/dataset/item-list.html.twig for listing the fields field_slider_images as well as field_blog_tags respectively of their's multiple values of the field.
I have selected "Unordered List" in the view.
Please do check the attached image.
I have created following files :
item-list--field-blog-tags.html.twig
item-list--field-slider-images.html.twig
But, this is not rendered for the listing of the fields.
When I have created item-list.html.twig then only it will access.
However, both fields have different data to style and I am not able to get the current field name which is loading it's data in item-list.html.twig.
Had a brief look at this and it doesn't seem that 'item-list' to have suggestions, which is quite unfortunate.
In this situation there are two options:
Create your own suggestion which would accomplish exactly what you need.
You'll have to do something like this:
/
/*add new variable to theme with suggestion name*/
function hook_theme_registry_alter(&$theme_registry) {
$theme_registry['item_list']['variables']['suggestion'] = '';
}
//send a value to newly added variable to use it build the suggestion
function hook_ENTITY_TYPE_view(array &$build, $entity, $display, $view_mode) {
//add condition here if field exists or whatever, do the same for other field
$build['field_slider_images']['#suggestion'] = 'field_slider_images';
}
//use newly added variable to build suggestion
function hook_theme_suggestions_THEME_HOOK(array $variables) {//THEME_HOOK=item_list
$suggestions = array();
if(isset($variables['suggestion'])){
$suggestions[] = 'item_list__' . $variables['suggestion'];
}
return $suggestions;
}
Now you should be able to use item-list--field-slider-images.html.twig
Second option is to do what others in core did: use a new theme
function hook_ENTITY_TYPE_view(array &$build, $entity, $display, $view_mode) {
//add condition here if field exists or whatever, do the same for other field
$build['field_slider_images']['#theme'] = array(
'item_list',
'item_list__field_slider_images',
);
}

Kentico CKEditor Configure Style Set Dynamically

I'm using Kentico 9 and I'd like to be able to use different CK Editor style sets on different pages. I have added a style set to the styles.js file as follows.
CKEDITOR.stylesSet.add("mystyles", [{ name: "testone", element: "p" }]);
Then in the page I've added some JS as per the CK Editor web site.
if (CKEDITOR.currentInstance) {
CKEDITOR.currentInstance.config.stylesSet = "mystyles";
}
When I load the page containing the CK Editor, the style drop down contains the default style set, not the custom one I defined.
Does anyone know how to achieve this?
If I remember it right you need to define your new toolbarset in config.js (CMSAdminControls/CKEditor/config.js) dropdown.
Something like:
config.toolbar_Basic = [
['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'InsertLink', 'Unlink']
];
The other thing - you need to add new option to this dropdown in Webparts application > EditableText webpart> Properties > HTMLAreaToolbar > DataSource
Here's the documentation you need to read.
The dropdown styles are defined in CMS\CMSAdminControls\CKeditor\styles.js, such as:
{ name: 'Italic Title', element: 'h2', styles: { 'font-style': 'italic' } },
You define the name of the style (the name appears in the dropdown), and then the element and style(s) that should be applied.
After editing the file, make sure you clear your browser cache.
As most Kentico admin interface pages are nested and iframe'd, the caching is pretty agressive, and your styles might not appear until cache is cleared.
Well, it's just javascript after all, so you can simply check the url in some if statement or in some switch-case and then apply styles you need. Do you need some code example? You should be able to find many of them on the internet :)
Here is how I solved my issue. I added the following to styles.js:
CKEDITOR.stylesSet.add("my-styles", [
{ name: "Paragraph", element: "p" },
{ name: "Heading 1", element: "h1" }
]);
Then, in the master page for the area of my site that needs to use the "my-styles" style set, I added:
<script>window.ckstyleset = "my-styles"</script>
Finally, in config.js I added:
var styleset = window.ckstyleset ? window.ckstyleset : "default";
config.stylesSet = styleset;
Using this approach I was able to customise the styles listed in the drop down depending on what master page was is use.

How hide header menu except repository in ALFRESCO5

I would Delete all voices in alfresco header menu excpet the repository voices how i can do there some template file to modify?
I tried with share-config.xml and share-config-custom.xml and nothing happened![enter image description here][1]
For hiding menu from alfresco share you will need to extend header.For the same you need to have some knowledge regarding "DOJO".In alfresco 5.0 for headers ,It is highly dependent on dojo. I have created one module for which code is like below which is written inside share-header.get.js.Location where you need to put file is shown in image.
var sitesMenu = widgetUtils.findObject(model.jsonModel, "id",
"HEADER_SITES_MENU");
if (sitesMenu != null) {
// Hide the site finder...
if (user.isAdmin) {
sitesMenu.config.showCreateSite = true;
}
else {
sitesMenu.config.showCreateSite = false;
}
}
Have you tried the 4.2 method?
http://blogs.alfresco.com/wp/developer/2013/09/04/customizing-the-share-header-menu-part-1/
http://blogs.alfresco.com/wp/developer/2013/09/04/customizing-the-share-header-menu-part-2/
http://blogs.alfresco.com/wp/developer/2013/09/04/customizing-the-share-header-menu-part-3/

How to add contents of HTML file to page dynamically from a Chrome extension?

From withing a Chrome extension, what's the best way to conditionally add the contents of an .html file to a page. Like you don't want to always add it, only if certain conditions are met. I see ways to conditionally inject script, but how can I conditionally add HTML from a file in the extension into the page?
If I have an option turned on, I want to add a block of code.
read option:
this.get_options = function ()
{
chrome.storage.sync.get({
mytopics: true,
friendtopics: true
}, function(items) {
self.settings = items;
scan_page();
});
}
this.scan_page = function()
{
if (!(self.settings.mytopics || self.settings.friendtopics))
return;
// want to add in a decent amount of HTML from a file, here.
// don't really want to construct it all via createnode calles
}
Figured this out.
$('body').append('<div id="containerName"></div>');
$('#containerName').load(chrome.extension.getURL("markup/notification.html"));

Template per url

I'm looking for an example of how to run a custom page template for a single url in drupal 6, would be nice to have a preprocess function too.
I used the following code in a recent Drupal 6 project; it requires entries into the template.php file which resides in the root of your theme folder. Simply drop the template page you create into the root of your theme folder, and you're off. {:¬)
You may have this function specified in your template.php file already; in which case, you'd probably have to refactor to add this. Here's the function in full:
function yourThemeName_preprocess_page(&$vars) {
if (isset($vars['node'])) {
$node = $vars['node'];
$vars['template_files'] = array();
switch ($node->nid) {
case '17': /* to override a specific node ID */
$vars['template_files'][] = 'page-my-page-name';
break;
default: /* to override a content type */
switch ($node->type) {
case 'page':
$vars['template_files'][] = 'page-normal-page';
break;
case 'my_own_content_type':
$vars['template_files'][] = 'page-my-own-content-type';
break;
default:
/* take no action */
}
}
}
}
Where I've specified 'page-my-page-name', note that Drupal (or rather, PHPTemplate) will add the '.tpl.php' part automatically.
This enables you to override by node ID first (more specific), and then more generally by content type, e.g. story or page. To add more overrides, just add more cases in the right place.
Hope this helps.
Humm, you might have to use the Module Panels3 and create a landing page. You can override every element of that page (even outside content area)

Resources