Sectioned PHP website like Wordpress [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am working on a PHP website, and don't want to have to write headers, footers, etc. for every page. I came up with the idea to have written headers and footers that could be retrieved with a function just like Wordpress. I found Wordpress's get_header(); function in /wp-includes/general-template.php but it loads through a template which I do not have being a hand written website. My question is "How do I write multiple PHP files such as header.php, and footer.php, etc. and compile them in to one document in the index.php?

Look into the include() function, along with the similar include_once(), require(), and require_once().

A. Make sure your index page is index.php and not index.html.
B. Write one header file, header.php, and use if/else statements to bring in the content you want for that particular page.
C. Use <?php include('header.php'); ?>at the top of your index.php and <?php include('footer.php'); ?> at the bottom of your page.
D. If this isn't working, make sure your server has PHP installed on it.

Related

Building a html, css & javascript pages for wordpress without php? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
So as the titles already states, is it possible to build a fully functioning wordpress page layout/theme using only frontend languages? And how will I incorporate it into wordpress without php?
Thanks!!!
Well no but you could certainly get away with using very little.
Just have
<?php get_header(); ?>
at the top of every page and
<?php get_footer(); ?>
at the bottom
A page named header.php with
<?php wp_head(); ?>
at the top and a page named footer.php with
<?php wp-footer();?>
at the bottom should get you going. From there just use html and javascript like normal.
HOWEVER this is leaving out 99% of the reasons to make a WordPress theme in the first place. It's a good place to start learning but if you want to make themes your gonna want to learn php.
This tutorial worked well for me.
https://www.youtube.com/watch?v=k7olvEeBM2I&index=3&list=PLpcSpRrAaOaqMA4RdhSnnNcaqOVpX7qi5
Good luck!

How to use php in html coding to reduce no. Of .html files? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have made the structure of a website. I have made three .html files named index.html, blog.html, posts.html. index.html is the home page and on that page their is a link for blog.html on the blog.html page thier are some posts heading and i have connected one post to posts.html. But now i'm in trouble that if i have to made one .html file for each post then it would be very difficult so what should i do so that i have to make only one posts.html and anyhow connect it to a php file or something else so that i don't have to make many .html file for every post.
Can i use php for it, is their any command that--> if you click on this post then this page will open and if you click on another post then another page will open. By this i will give the command for all the posts and it will help me alot.
Thank you
Try file_get_contents php, or create a small ajax client to load html.
$your_html_file = file_get_contents('./test.html', FILE_USE_INCLUDE_PATH);

Combining one webpage section into other webpage [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have downloaded a several nulled website templates for testing purposes.
I was wondering if I could combine them into one webpage?
For example, take category page layout from one webpage and implement it to other webpage. Is it possible to create webpage using php and html files combined, lets say index.html and contact.php?
Thank You in advance.
YES, you can. But, it's fairly not easy though.
When you are combining two different templates, each have seperate stylesheets and possible Javascript/JQuery scripts, which conflicts between the two.
And you can combine php and html files in same file.
Just use <?php at the beginning of php code and ?> at the end of php code.
Hope this helps. :)
Yes, it's just a matter of copying the section of code from one file and pasting it in the other. Which is why templates are available in the first place. But notice that you can't go copying PHP code and placubgit in a .html file.

How to get codes from another page? (Basic PHP) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want something like Wordpress's system. I want to get header code from header.php so I will not have to edit all of the pages when I'm going to edit something.
You can never get the code because one the php page is render, it gets converted into HTML so you will always see html.
I understand, you need header component.
1)Create a file header.php (add navigation bar or logo or whatever you want).
2)Include it in other php files as include("header.php");
so all the pages will be using this one header.php file and you can modify it and the changes would get reflected all over the web app.

Default php include on all pages [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
On my site I have overall header and footer that are being created by functions header() and footer(), accessible in overall.php file. All sites are based on the same template so it looks like following:
<?
include ("/overall.php");
header();
echo "<div>";
// content of site
echo "</div>";
footer();
?>
I am thinking about another solution - maybe make a function createsite($content):
<?
function createsite($content)
{
header();
echo "<div>".$content."</div>";
footer();
}
?>
so that it would be simplier to create new page (there will be more than hundred of them). What are your ideas? I have been thinking about something like default include of overall.php on all sites. I hugely prefer clear PHP over frameworks like symfony or zend.
You will probably end up doing the same thing all of the frameworks are also doing, which is having a single point of entry for all your pages which will include all the neccesary functions (such as those in overall.php) and then redirecting the user to whichever actual page they want to see by including that as well.
Keep in mind that what you're currently building is (or rather, will be) a very basic framework in its own right.

Categories