I have a joomla component and I want to have a custom template depends on the resolution.
I have default_list.php file where I want to include a php code to load a specific template (default_list_template1.php) depending on the device resolution.
Can someone give me a clue?
Since there is no simple way to get screen-resolution with PHP (server-side language), and moreover, resolution may change over time (screen resize), it is much better to start with responsive CSS well explained at http://learn.shayhowe.com
If you want to dig on your own, use "responsive website" and "CSS media queries" search phrases.
Related
I have a Wordpress site with the "baskerville 2' theme installed. I've been using google page speed insights to assess my site's loading speed.
It tells me that the font awesome Webfont preload request is slowing it down.
I've added :
<link rel=”preload” href=”https://dsbaudio.com/wp-content/themes/baskerville-2/fontawesome/fontawesome-webfont.woff2?v=4.3.0” as=”font” crossorigin=”anonymous”>
to the header.php and this has improved things a bit.
If I understand things correctly, would the site load a lot faster if the theme didn't preload web fonts at all?
Is there a way to modify the theme (using a child theme edited offline) to revert it to standard fonts like Arial, Times or Georgia?
Though it is an excellent resource, it is likely that you do not need the entire FontAwesome font file.
I often use maybe 10 of the glyphs available in that file. If you load the entire font – something like 7,000 glyphs – then you are drawing unnecessary system resources to define 6,990 glyphs that you will never use.
The answer:
Subset thy font, good programmer!
To do this, I use a font-subsetting service. They tend to be free, and there are easy-to-follow instructions on their sites. There are several, but you could try fontello: http://fontello.com
I just had a look at a fairly large set of icons that I use on one of my sites, and it was 44KB. Tiny. Fast.
Let me know if you have any questions.
Have you considered placing the code in your footer instead? Some websites claim this increases load times.
Alternatively, with relation to choosing default fonts, yes - either through modifying your CSS, or changing the font within your theme options. You should be able to change it there... I'm not familiar with your theme sorry I could not be more specific.
You need to perform two steps process to solve this issue.
Step one: Go to
appearance ->theme editor ->framework/dist/css/site/stacks/(yourstacks).css look for #font-face and replace with font-display:swap;
Step two: Go to appearance ->theme editor ->framework->fonts->font_awesome
Insert this line of code inside the font tag
font-display=“swap”;
While i am still learning css html5 and Jquery, combined with the information from the internet, i came up with a idea to program the css in to different chapters, and call them in to the head section when need it.
from my understanding, via google it is faster to load css styles in the head as a <style></style>.
This way i will only have the css at the page that i need, and it will be better readable for me, becouse i dont use html css styling in dreamweaver anyway.
My css is now so big it is taking tomutch time to find it all.
even with dreamweaver search box.
Does any one have experience with this, or see any problems i might incounter?
Thanx in advance..
The only way to create structure if you're working in a big php project is to save a blank html page, load the existing css on to that page, use the css options/panels in dreamweaver and load the body parts you need in there.
If your using a dynamic css location link, other wise, i think dreamweaver will do just fine in php.
Not sure becouse i never used it that way...
Situation
i try'd to make more sence doing it this way, but i have just put everything back, becouse i got a unknown error, did not investigate it further. And the <style></style> has the highest level of design, meaning all the rules that where set, will be overwritten, things will get complicated fast if you start moving parts aspecialy if have a multi css styling site, so it is not recommended if you already have a big project, do it from the start...
Edit * 27-11-2015
I found the solution, i am using classes to slowely but surely replace the css file...
I have dozens content types in which I need to display more or less block of the same fields. Using core display I have to create many groups and even than styling them with css is tricky.
My alternative is to use template suggestions but will they render faster than normal display method I'm currently using?
It will be easier to remove thoose fields from display, write the templates and render node in template (all the other data).
But how about performance?
Any help will be appreciated
Thanks
Although the answer is not so specific I would say that printing what you need in tpl.php files is faster than hidding them with css or php if conditions. So you should better use tpl.php files for each node type. And "core method" you are talking about is using tpl.php files! Look inside ROOT/modules/node folder for the tpl files of node module.
There are also some useful modules to help you with that like display suite, panels, entity_view_modes etc but if performance is a big issue you can go without them.
I'm using CakePHP to build my site (if that matters). I have a TON of elements/modules each having their own file and fairly complicated CSS (in some cases).
Currently the CSS is in a massive single CSS file, but for sanity sake (and the below mentioned details), I would like to be able to keep the CSS in it's own respective file - ie css/modules/rotator.css. But with normal CSS, that would call a TON of CSS files.
So, I started looking into SASS or LESS per recommendation. But - it seems these are supposed to be compiled then uploaded. But in my case, each page is editable via the CMS, so a page might have 10 modules one minute, then after a CMS change it could have 20 or 5...etc. And I don't want to have to compile the CSS for every module if it's not going to use it.
Is there a way I can have a ton of CSS files that all compile on the fly?
Side note: I'd also like to allow the user to edit their own CSS for a page and/or module, which would then load after the default CSSs. Is this possible with SASS and/or LESS?
I don't need a complete walkthrough (though that would be awesome), but so far my searches have returned either things that are over my head related to Ruby on Rails (never used) or generic tutorials on each respective CSS language.
Any other recommendations welcome. I'm a complete SASS/LESS noob.
Clarified question:
How do I dynamically (server-side) combine multiple CSS files using LESS? (even a link to a resource that would get me on the right track is plenty!)
If you want to reduce the number of CSS files & you have one huge css file that has all the component css, just link to it on all pages & make sure you set cache headers properly.
They will load the file once and use it everywhere. The one pitfall is initial pageload time; if that's not an issue go with this solution. If it is an issue consider breaking down your compiled CSS files to a few main chunks (default.css, authoring.css, components.css eg.).
Don't bother trying to make a custom css for each collection of components, you will actually be shooting yourself in the foot by forcing users to re-download the same CSS reorganized in different ways.
Check out lessphp (http://leafo.net/lessphp/). It's a php implementation of less and can recompile changed files by comparing the timestamp.
Assuming that 'on the fly' means 'on pageload', that would likely be even slower than sending multiple files. What I would recommend is recompiling the stylesheets whenever a module is saved.
The issue of requiring only necessary modules should be solved by means of CMS. It has nothing to do with SASS or LESS.
If your CMS is aware of which modules current page has, do not run a SASS/LESS compilation (it will be painfully slow unless you implement caching which is not a trivial task). Instead, adjust your CMS's logic so that it includes each module's CSS file.
Advanced CMSs like Drupal not only automatically fetch only necessary CSS files, but also assemble them into a single file and compress it.
And if your CSS is not aware of which modules current page has (e. g. "modules" are simply HTML code that is saved into post body), then you can't really do anything.
UPD: As sequoia mcdowell says in his answer, making users download one large CSS file once is better than making them download a number of lesser CSS files that contain duplicate code. The cumulative size of all those smaller CSS files will turn out to be larger than the size of a full CSS file.
I'm using Drupal for the first time for a project at work. I'm finally getting my head wrapped around some of the core concepts, but when it comes to customizing output I'm unsure of how to proceed.
I have to build a fairly specialized image gallery. I've managed to cobble something workable together using Views2, but it's not quite where it needs to be. I'd like to write it from scratch, using SQL and actual PHP, rather than working through this web UI.
I figure I'll put this functionality in a new module. Is that right? Or is that an abomination to the Drupal world?
Edit:
Here's what I've got so far. I've created Image Gallery and Image content types with CCK. Images can be assigned to multiple galleries, via nodereference. I've got imagecache creating two sizes for each uploaded image - a thumbnail size and a gallery size.
Two gallery formats are required, but let's assume I'm going to have a carousel style for now, with some custom JQuery and CSS to match the rest of the site's look and feel. Clicking a thumb in the carousel-style navigator will load the full sized image above it.
Now, assuming such a thing does not exist, what is the recommended approach for creating it? Not how to code it, but where would this code live within the Drupal system?
It seems like views will do the job of creating the data you need - a list of all the images for the galleries, based on whatever criteria you need (taxonomy,author or whatever) and that the carousel part - adding the jquery and css could be done by using drupal's themeing system to change the output.
So as ar as 'where would the code live' I would say in your theme, rather than a module.
The views theming system is pretty comprehensive, if possibly a little overwhelming at first.
This looks like a good starting reference: http://www.group42.ca/theming_views_2_the_basics
You can do this. Views is great but will often only get you 90% of what you need out of the box.
You can do views theming, which can take you further, and you can write extentions to the views functionality (but that is not always easy).
There is nothing wrong with writing your own module in stead of views, in some cases it can increase performance. One tip if you are doing this is that you can see use the query that views creates in your custom module, this can save you having to work it out and write it yourself.
Yep, I'd put this in a module. I often wind up writing custom ones for specialised use cases.
Well since it is free software you are free to do (almost) whatever you want with it.
A good practice to decide if you should do it is:
Will the benefits that I will get from
a custom module divided by the time
I'm going to invest in it. Outweigh
the benefits / over time of a solution
that isn't ideal?
Or if you prefer to look it this way:
Custom Development Benefits Not 'ideal' solution benefits
--------------------------- > -----------------------------------
Development Time Time to install and adapt
Since normally the Time to install and adapt normally is smaller than the time to develop something from scratch, the common conclusion is to just use what is already there.
But by all means if you want to develop your own thing and have enough time, go ahead.