Do html and php use the same css file? - php

for example: you created a website and in that website you want to create a login page using php. Do you use the css file that you design your website with, to design login page?

You can use a single CSS page to style your whole website if you want to . You will just have to make sure you load in every html file that you load in the browser.
I would suggest splitting this up css file into parts if you expect your application to grow bigger.

PHP actually runs on the server and it renders html (usually).
So if the template you're rendering with php has the same css file included you could use the same css for both pages.
Now for your needs, the login page has possibly some css that your other pages don't need. I would suggest creating a common.css file with everything that both pages will have and another with the login page specific styles.
I hope that's what your looking for.

Related

Should I add home page HTML in wp classic editor or front-page.php for speed?

The title basically says it. I currently have my home page with the HTML sitting in the classic editor box. Should I move that to front-page.php? I know that it doesn't REALLY matter, and it won't have a huge impact, but I am being meticulous about creating a speedy website. So which is faster?
Also, I am currently using 2 separate PHP files for headers. One on the home page, and one for the rest. Should I just hard code the header for the home page into the same place as the home page HTML since it's the only page that uses it?
I'm pretty new to PHP, but I've searched Google extensively and can't seem to find my answer. Using WordPress. Really appreciate your help!
For speeding up the website, no need to change the home page or the header file. please do the following things for speeding up the website
Optimise your images
Enable caching
Enable GZIP compression
Minify CSS, HTML & JS files
Update plugins
Clean-up your database
Moving the html code to a template file will improve the site speed because WordPress will not have to retrieve those html tags from the database. And it is conventional and actually a good practice to place all rendering code (html, css, js) to the template or theme files where they should be, instead of directly adding them in the backend or instead of including them directly in the post editor.

Is it good or bad practice to use an iFrame to insert a large amount of local content into a Lightbox?

I am creating an enquiry form which opens in a Fancybox pop-up but a little unsure as to how to correctly insert the content.
The form has a very large number of fields, so I think it would probably be best to have the code in a separate file, making it easier to read and be edited in the future, if the need ever arose.
I am aware I could create a separate file and include it into the page via PHP or SSI but wanted to get an opinion from others as to what the best way of getting the content in would be. I am veering away from changing the page which has the link to the form to .php (which is currently .shtml), as the website I'm working on is very old and doesn't have any PHP pages in it but does use SSI for the navigation and header sections (all pages in the site are .shtml).
Should I use SSI, an iFrame or just embed the code directly in the master page and forget keeping the form separate?
I look forward to your suggestions.

How do I preload .css and .js files, before the whole page (dynamic by PHP) is generated

My homepage (index.php) is generated dynamicly by PHP, so it takes about 1s till the the page is delivered to the user.
Because my css and js script is in the header of (index.php), after this 1s the css and js will start to download.
Is there some general way of preloading this js and css files?
My aproach would be to delete all content of index.php, include just <'head> with my css and js file, and then do some js to load the whole indexOriginal.php (with the dynamic content generated on my server by PHP), so this should enable the user to download the css, js in parallel of indexOriginal.php.
Is this the right aproach?
The approach you suggested could work. You also might consider altering your PHP script to hurriedly deliver the first part of the page (<html> down through <body>) before it starts getting the rest of the page together (see http://php.net/manual/en/function.flush.php).
Your page full generated by backend and sended to user only after php script end its work.
You could, for example, create page like.
<html><head><script></script></head><body></body></html>
In <script></script> load, for example, JQuery and do something like
$(document).ready($('body').load('/path/to/your/script.php'))
But I really thing this wouldn't be a good practice. Also I don't think that Google would parse your site content with this solution.
I think you should look better about your JS (compress, gzip, split to many files and upload them from different CDNs, move everything to $().ready, etc.)
My recommendation would be to have your initial PHP script JUST deliver the CSS and JS tags. Once those are loaded, use the JavaScript to make an AJAX call that gets the rest of the page then displays it. Or you can build the page in the JavaScript (which would allow you to use loading icons and the like to give a better indicator to the user that "the page is coming")

Load a div from external source

I am trying to load a div from another domain and display it on my site. An <iframe> will not work as the content is dynamically sized and I don't wish to render the entire page, just the content of <div id="content-article">
I have attempted to follow the guide from: http://frinity.blogspot.com/2008/06/load-remote-content-into-div-element.html however after reading the comments it appears to only work for external pages on the same domain.
I don't really care how it is done; php, jquery, ajax or what have you I just don't want to upload the same content to two different domains.
Is there any way to do this?
You can't when it should fetch it from external URL. Perhaps you can create a proxy or so and do a jquery.get?
You could use PHP's DomDocument to parse the HTML of the page that has the div and extract the div you want and then put it into your own content.
What is the URL with the div you want to grab? (Maybe we could write some code to help you pull it out.)

How to edit the files of an osCmax site

I have a website running on osCmax setup by a developer a while back and now I want to restyle some of the pages myself from the markup and CSS only.
I'm familiar with HTML/CSS and some jQuery to an extent but I have never touched any PHP. This is my first time really getting into any of the osCmax pages, site, etc., myself so I am little confused on what it really is or does.
If I want to edit any of the HTML/CSS myself for styling pages will I have to download and login to the osCmax admin panel to get to any of the files?
Or can I just go directly through my server to grab the appropriate HTML and CSS files? Wouldn't all the necessary files from the download be on my server already or is this something that I have to download to use?
If all you want to do is restyle the pages, then just modify the css. You shouldn't need to modify the PHP (unless parts of your HTML are created with out a class or id).
oscmax has a seperate folder for its template. all you have to do is editing the .css file. but sometimes you need to design the template from scrath and since the OSCMAX is outdated you must edit all the pages with .tmpl prefix.

Categories