Im working on a CakePHP application that will display a DVD collection. I would like to include a Dropdpwn Menu where the user can select their on view/colour scheme. Nothing fancy, it just needs to either change the layout file for the CSS file. Either will work.
Any tips? Can't seem to figure it out.
Regards,
Jon
Use Themes to switch either layout, css, or both.
In your AppController.php add:
$this->theme = 'Fancy';
This will look for your default layout in App/View/Themed/Fancy/default.ctp. You choose what you want to customize with a theme. If you don't have a special layout file for the Fancy theme, CakePHP will default to App/View/Layouts/default.ctp. Likewise, you can choose to provide a special stylesheet in your theme which would go in App/View/Themed/Fancy/webroot/css/default.css and if not CakePHP would use App/View/webroot/css/default.css.
You can set the user's theme selection to a Cookie so it's remembered.
You didn't say which version of CakePHP you're using, but the solution will be similar in either 2.x or 3. The above links are to the 2.x Cookbook.
Related
I'm looking to edit Drupal's admin pages.
Some of the things I'm trying to achieve:
Remove is the the filter setting on the Content page/node/view. In other words, if I go to to the Content page and I filter by a certain type of node, then I leave that page, then come back, the filter setting is saved, I'd like it to reset each time I visit the Content page.
I would like to modify some of links associated with these pages, as an example on that Same Content page, the titles of the pages are linked to their 'front-end' views, I'd rather have them link to their 'edit' screens.
While I have been successful in modifying the front-end theme of Drupal, by editing the actual php files. I can't find the the same php files for the Admin theme. In our case we are using Seven (7.21). I've read something about views, and thought maybe the entire Admin theme is built as views, aka there no php files involved like the front-end theme has, but under the Views section I did not find any either. I'm still pretty new at this and coming from the Wordpress world, this is a Drupal is a lot different.
The logic for that section of the admin area is at (from the public root):
/modules/node
Specifically "node.admin.inc"
That being said, I don't recommend editing core scripts, as they will be overwritten when you update the core.
You could explore making your own module to supplement that page, or your own view or explore some pre-made modules, such as "Admin Views"
Find de view displayed and go to its configuration :
1 - Edit configuration view like suggested here : https://drupal.stackexchange.com/questions/44440/how-to-remember-exposed-filter-choices
2 - Rewrite output views to rewrite link : field https://www.drupal.org/node/1578524
Another option is to create and use your own dashboard/views to achive like you want http://definitivedrupal.org/suggestions/creating-custom-administrator-view-content
also you can see contrib module : https://www.drupal.org/project/admin_views
You don't have to use that default content overview page at all. Make your own instead:
Make a page view (you have to install views module if you already did not: https://www.drupal.org/project/views) and use table layout. Make sure that page paths starts with "admin" so it will use admin theme. Also pay attention about permissions, so only specific set of users (admins) can use it.
For that view you can freely select what columns you what to show. You can also allow ordering by any column and action if you click on some field.
Use exposed filters to add filtering form, again add any filters you need. You can even set the form to use AJAX, to do auto-submit when some filter field is changed, include reset button and more. Also for every exposed filed you can select (at fields settings) should it remember it's value or not.
At end, edit admin menu and add your new page to it so it will look and act as default one but will offer much more functionality. You can even totally remove default one from the admin menu.
Views module is very powerful, not only for front-end but also for back-end content handling.
In my AppController i'm assigning the active theme like this:
$this->viewBuilder()->theme($this->Themes->active_theme());
I've created a page which shows all my themes (I'm using a json file for this), i want to add a preview theme functionality to every theme in my page just like wordpress, drupal etc.
I'm not sure how to can i temporarily load a theme using app controller for previewing purpose.
Any help on how this functionality works and how can i do it in Cakephp would save my day.
In your preview function, call $this->viewBuilder()->theme($previewTheme);? Seems pretty straight-forward, am I missing something?
I'm creating a new Drupal theme for news web sites, which needs some fields to be added to the Article content type to work. For example, the theme will change the header image into something science-related when the user is viewing an article tagged with the term "Science" of a taxonomy called "Section".
I have set up the "Section" vocabulary and added it as a field to my Article content type manually, but the theme I'm making should be "shippable" to end customers, meaning that someone should be able to download it and install it without manually creating taxonomies and fields.
The theme must in some way notify the user that it depends on the Taxonomies module, and, when installed, the theme must create the relevant taxonomies and add fields for it to the "Article" content type.
What is the best way to accomplish this in Drupal 7? The only way I can think of is to create a specific "installer module" for my theme, that officially depends on Taxonomies and are able to add the right fields to Article etc, but there must be a more robust and "standard" way to accomplish this?
Making a theme depend on modules isn't very "standard". Themes only deal with the display, while modules deal with function. If you're making this theme only for this client, I wouldn't bother trying to integrate the two. Now if you're wanting to keep this for down the road, then it's like an installation profile, or themes you would see on ThemeForest that come bundled with a database.
I'd recommend moving any non-theme parts (like content type, fields, etc) into a feature using the Features module. It will help you keep your functionality separate from the theme. If you want to add custom CSS into the feature, just use the drupal_add_css() hook the in .module file that gets generated.
We have developed a CakePHP (1.3) application which works fine. Before usage users have to login. Nothing new there.
We also created a plugin containing a "sales website". It's styling is completely different from the applications design. The sales website works ok, but the loginpage is now based upon the applications layout (path: /users/login). We would like to apply the sales websites layout. But only when the plugin is available.
Is this possible? And if so, is it possible without the need to add a login method and/or users controller to the plugin?
You can use App::objects('plugin') to get a list of available plugins in your app. just do an array_search fro your plugin name and switch the layout accordingly
I need to change the theme (let's say default theme = classic) to the iphone theme (or whatever) when the user has navigated to the liferay portal using a mobile device.
I thought to go about it like this:
- create a hook to gets triggered on a user login event
- check for the device using the User-Agent request header attribute
- if required, set the theme to iphone using LayoutServiceUtil
Probably there is a better approach to implement such a requirement so feel free to offer alternatives.
I'm quite new to liferay so that is probably the reason I could not get this to work.
a. First of all I'm very confused about how themes are handled in liferay; there seem to be various related model objects which are hard to distinguish: Theme, ThemeDisplay, Layout, LayoutSet, ColorScheme, ... . Can someone explain this or know where this is explained?
b. apparently you need to get the ThemeDisplay from the request in order to set a theme on it. However, when the user logs in, the theme attribute (THEME_DISPLAY) has not been set yet (neither in the pre nor post event; it is set when I check during a logout event). Setting the theme during login is an absolute minimum, I was actually hoping I could set the theme before the user logs in but since the attribute is not even known after user logs in...
c. when using LayoutServiceUtil.updateLookAndFeel, you need to give the groupId, themeId, colorSchemeId, css, ... . I was expecting it would be simply telling liferay which theme (name) to use no matter what groupId, ... . Is this not possible?
thanks a lot for any help,
Stijn
P.S. I'm using liferay 6.0.5.
I haven't tried this myself but I'm planning on looking into it:
Milen Dyankov's extensions seem to have a way of letting you select themes based on the user agent all configured in the control panel. You can read his blog about it here.
I could be mistaken but I'm pretty sure the switching happens automatically.
Question a: are you developing your own theme or do you just want to customize it?
Question b: why not set the default themes correctly? Just set it in the settings pannel => layout => dropdown at the bottom
Edit:
I would be wary of using a login.pre hook. While this will update it when you login it means that untill the user actually logs in they may see the wrong theme. I would check it in the default render mode of a portlet on the main page or find a hook that is used on first visiting the page.
A possibility seems to be: servlet.service.events.pre
That way it will be checked every http request. There may be better options. (I am not that familiar with liferay)
And to get the groupId etc you can just use: long groupId = ParamUtil.getLong(actionRequest, "groupId");