Drupal 7: How to create a "shippable" theme? - drupal-7

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.

Related

React native application theming

I have a question related to React Native.
I have existing application that should be themed and theming should be part of the configurable settings. There should be 3 aspects of such theming: changing colors/theme, changing logo and add custom fonts
I see this is a way that there will be settings view where:
there will be possibility to upload image, image will be stored in filesystem in ios and android and then used as a brand logo
there will be multiple settings regarding some primary, secondary, buttons colors as hash values, or maybe some color picker component
The most complicated stuff is having custom fonts that can be configured by user in setting view of application. Anybody have experience with doing such a thing?
Any thought/suggestions in above points will be helpful. Like links to native libraries for both platform or any tips from more experiences React Native developers
The best ways I see to achieve what you want are :
Use https://github.com/itinance/react-native-fs to access file system so you can easily store and access the logo that the user want. If the image has some size restrictions you could as well store your image Base64 string in AsyncStorage but this is not recommended.
You can have a kind of theming system by using a global style file that your screens use, the values requested (for example "dark", "light" etc...) can be store in AsyncStorage.
Do you want the user to be able to use his own personal font ? I don't think this is possible. If you want to have multiple fonts and the user can choose which font will be used in a list for example you can follow this tutorial to install custom fonts : https://medium.com/#kswanie21/custom-fonts-in-react-native-tutorial-for-ios-android-76ceeaa0eb78. Then all you want to do is use your theming system to select the fontFamily that your text elements will be using !
Let me know if I'm not clear enough or you need advices, I recently did what you try to achieve :)

React app with different themes

let me share my problem with you. To begin with I'm a junior-mid level web developer currently implementing a travel site. To deliver this I have a task in which I cannot find an efficient solution.
This travel site will be provided in different hotels. For each hotel, the main theme for the app will be different for example the background images, the colors of some buttons etc. My first suggestion would be to have the CSS files for each hotel and by reading the name of the hotel from the state to import the according css. But the hotels will be many and by using so many files my bundle file will be enormous which I don't need. Another solution would be sending all the colors and images from the server but this will have a use impact in my code and I will have to refactor it in so many places. The idea of the server is fine I think
But I want to use some theme template to makes these changes according to the server. Do you know something about that?
I think there is no need to send all the colors and images from the server. You can store all of it on a frontend part and get only a type from the server and apply different styles based on this type. Maybe this library can help you here.

How do I modify Drupal's Admin Screens?

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.

CakePHP - Letting the User Select the Layout

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.

Managing links in silverlight applications

What is the best way to manage links in a Silverlight application? In my app, I have various custom controls that will open a new website in a new window.
I know in the hosting aspx page you can pass in parameters but I don't know how and where to store these links internally? Should I add a collection to the App object? Is there another mechanism that already exists? Is it a good idea to make my custom controls take the links from a global scope object or the links should be passed in the constructor?
How do you do it?
You have lots of options in Silverlight depending on what type of links they are, how many and how you want to maintain them.
If they are referenced by ID and updated occasionally, you could store them in a resource dictionary or a custom XAML file and load that on demand (XAML files are just object descriptions after all).
If you need to constantly maintain them, a database on the server would store them centrally and you would fetch them as needed via a service.
For lots in individual custom controls, that don't change links often, you could just make the hyperlink URL a property of the object and set the links in the XAML that contains the controls (this is the simplest option for the simplest usage). e.g.
<customControl Hyperlink="http://mylink.com/path/params/etc"/>
Basically it comes down to how you want to manage them. If you drop us a line via our website contact page with specific details we will be happy to provide more detailed examples/suggestions.
Hope this helps.

Resources