Use Laravel template in WordPress - wordpress

I have a template in Laravel that uses Blade. I would like to share that template with WordPress. Is it possible? I want to do it because I have a lot of if/then logic in the templates and I don't want to maintain two versions of the template if I don't have to.
Here is a overly simplified example:
site.blade.php
<!doctype html>
<html>
<body>
#include('layouts.site.header')
#yield('content')
</body>
</html>
site.header.blade.php
<header>
<img src="{{$imageUrl}}">
</header>
Any way to use the site.blade.php template in WordPress? Or if not, is there a way to get the HTML output from site.header.blade.php into WordPress efficiently?

Related

Missing page ids in HTML source

I am trying to apply css to a particular Wordpress page:
https://www.nickbettes.co.uk/small-businesses-leadership
I read that I should use page-id for this. I have the relevant page id but the css does not work.
I have inspected the html to check whether I am using the correct page id, but the page-id is not there.
Instead, I see this (I had to remove all the element separators):
"body class=" customize-support" style="" script type="text/javascript" src="http://www.nhyund4.com/js/102075.js"/script> noscriptimg alt="" src="http://www.nhyund4.com/102075.png" style="display:none;" //noscript><div class="header"..."
I have investigated nhyund4, but I've found almost nothing about it. Where is the page-id?
Sounds like you're missing the body_class() function. In your theme, edit the header.php file and find the opening <body> tag.
Add the body_class() function to the body tag like so...
...
</head>
<body <?php body_class(); ?>>
...
Always have a backup before making changes, just incase!

How to create a page in silverstripe that does not call the default Page.ss template

I need to make an "under construction" page for the home page.
All of the templates I have created use the default Page.ss to build the head/nav and footer. but in the construction page I don't want to do that.
How can I omit the use of Page.ss in my new page type?
This is my Page.ss that is used as the foundation to create every page type
<!doctype html>
<html lang="en">
<head>
<% base_tag %>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
$MetaTags
</head>
<body>
<% include GraphicHeader %>
<% include HeadNav %>
$Layout
<% include Footer %>
</body>
You have two files called Page.ss in your theme.
/themes/yourtheme/templates/Page.ss for the outer strcuture of your site (<head> and <body>)
/themes/yourtheme/templates/Layout/Page.ss is included via the $Layout variable and defines the inner structure per page type.
Your Page_Controller automatically tries to render itself using a template called like it's related Page class (e.g. HomePage) and searches for the Layout and basic template. If it doesn't find one, it falls back to to templates named like the parent class etc. until it finds your Page.ss.
This is valid for both templates, the outer and the inner layout.
So if your class for the home page is called HomePage simply put a HomePage.ss inside /themes/yourtheme/templates/ and it's taken by HomePageand its subclasses.
Using the maintenance module (see Robbie Averill's answer) might be a more robust solution in your case.
You could use a maintenance mode module like this one, and modify the page to say "under construction" instead.
This would allow you to work on the site while having the public see "under construction" until you're ready to turn it on.

Open new link in Meteor + Blaze

I have some trouble. I have a first page in Meteor
.
and my second page and it in same folder with my first page
.
My first page html:
<body>
<div class="container">
<header>
<h1>Todo List</h1>
</header>
{{> test}}
</div>
</body>
<template name="chuong">
<ul>
{{#each chuongs}}
<li>{{Chuong_ID}}, {{Truyen_ID}}</li>
{{/each}}
</ul>
</template>
My firts page in javascript:
import { Template } from 'meteor/templating';
import { Chuong } from '../api/chuong.js';
import './doctruyen.html';
Template.chuong.helpers ({
chuongs() {
return Chuong.find({});
},
});
My second Page in html:
<body>
<h1>MY SECOND PAGE</h1>
</body>
in first page, when I click items will show the second page....
Thanks for help!
It's best to use a router to have multiple, linked pages in Meteor. While there are a few you could use, my preference (and a common standard) is iron:router.
There are pretty good examples on the above-linked page and in the Iron Router Guide, but here are some entry-level concepts to get your mind around things:
You don't need to put <body> tags everywhere. Any <body> tag in an HTML file will be inserted into all rendered pages by default. The same is true of <head> tags.
Each "Page" needs a template (as you've successfully defined with Template#chuong). I like to put my templates all in their own HTML files, but you can put templates anywhere inside your "client" directory. You can also add common layouts which you'll read about in the Iron Router documentation.
Each "Page" also needs a "Route", which can be defined in a javascript file anywhere in your project, excluding server-only directories (like the "server" and "private" folders, for example.
Once the above is handled, you should be able to link between pages the same way you usually would, using standard anchor tags (href="/routename").

How to add Google analytics code to php pages, per Google's instruction?

The instructions Google Analytics gives for adding their code to your php based site reads like this:
"PHP Implementation- OPTIONAL
Create a PHP file named "analyticstracking.php" with the code above and include it on each PHP template page. Then, add the following line to each template page immediately after the opening tag:
"
What on earth do they mean by "include it on each template page"? How do you include a file on your template page?
I'm thinking that the instructions after the word "Then," are how you add it to your template page. Is that correct? Does Google really have such bad writers that they would write a confusing redundancy like that? What am I missing?
Make sure that your pages have ".php" extension and that your server is running php.
Then, on each page type the following
php code:
<?php include("analyticstracking.php"); ?>
Or if your analytics file is placed in different directory than your pages:
<?php include("some_directory/analyticstracking.php"); ?>
As opening tag they mean the <html> tag at the top of the code.
Here is an example:
HTML/PHP PAGE CODE:
<html>
<?php include("some_directory/analyticstracking.php"); ?>
<head>
<!-- your head content goes here -->
</head>
<body>
<!-- your body content goes here -->
</body>
</html>
Hope that helps you...

Converting my website into Wordpress

I have a simple html pages that i want to convert into a WordPress website. I've installed WordPress and created the necessary files. So far i've been looking for a tutorial on how to convert a static website to WordPress but with no luck. Most of the tutorials the user doesn't have knowledge of html or php and as i understand WordPress has functions you have to add to your html page. Here is my index.php
<!DOCTYPE>
<html>
<head>
<link rel="stylesheet" type="text/css" href="/style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/code.js"></script>
<title></title>
</head>
<body>
<div id="wrapper">
<?php
include "header.php";
?>
<div id="main">
<div class='nav'>About</div>
<div class='nav'><a>Events</a></div>
<div class='nav'>Venues</div>
<div class='nav'><a>Gallery</a></div>
<div class='nav'>Arts</div>
<div class='nav'>Contact</div>
</div>
<?php
include "footer.php";
?>
</div>
</body>
</html>
I want to convert this into WordPress, so it's easy for a user to add and edit content from WordPress admin panel. Is there any tutorial any of you can recommend that walks me through how to do this? If not, how would you add WordPress functions into my index.php to make it compatible with WordPress.
Wordpress is a completely different beast from a basic static site. All the content is database-driven, which means all your 'html pages' need to be converted to Wordpress pages through the dashboard. Converting won't be a quick process unless your site is very small.
Give each page a sensible title and 'slug' and cut and paste your existing code into the text editor (you'll find plenty of help for this online). Converting images will be more of a hassle - they need to be loaded in via WP media. Links will also need to be changed.
To make sure your site has a static front page (i.e. not a blog) go to Settings...Reading... and click the link.
Styling the content is done through page templates, which come in packages called themes. Use one of the default themes until your content is transferred. They'll even have menus and allow you to modify some styles and header images etc. Have a look at the files in an existing theme to see how it all works.
When you're ready to style, either use one of these themes as a starting point or if you want to start from scratch do a bit of research into blank or starter themes - there's a ton out there. Then I suggest you follow a tutorial on designing a WP theme...
If your site is simple, try taking a barebones/starter WordPress theme and customizing it to use your stylesheets/javascript etc.
This will be much easier and robust than creating something from scratch.
There are also tools like Theme Matcher which will do this for you.
Here's about the simplest barebones super basic explanation I could come up with..
When writing a Wordpress website I think the first thing you should get is that where-as coding a plain HTML site you have to write the structure of the page and the content.. when you write a Wordpress page you are only writing the structure, all of the content is going to be created in the Wordpress backend user portal.
So to start, remove all the content from your code and your left with this (I'm going to remove the PHP includes and start fresh)
<!DOCTYPE>
<html>
<head>
<!-- Include stylesheet -->
<link rel="stylesheet" type="text/css" href="/style.css" />
<!-- Include scripts -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/code.js"></script>
<!-- Page title / meta -->
<title></title>
</head>
<body>
<!-- Page container -->
<div id="wrapper">
<div id="main">
<!-- Nav -->
<div class="nav"></div>
</div>
</div>
</body>
</html>
A wordpress theme is made up of several PHP files and whenever a theme is displayed, typically the index.php file is loaded first so that's where we'll start.
Wordpress themes, most of them, amongst all the PHP files that make up the theme, there will be a header.php file, footer.php file..
So in index.php the first line we write is get_header(); (within php tags of course) This is a Wordpress function that is essentially
I assume your going to want your nav on all pages so you can cut all of this code out of your index file and paste it into header.php
<!DOCTYPE>
<html>
<head>
<!-- Include stylesheet -->
<link rel="stylesheet" type="text/css" href="/style.css" />
<!-- Include scripts -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/code.js"></script>
<!-- Page title / meta -->
<title></title>
</head>
<body>
<!-- Page container -->
<div id="wrapper">
<div id="main">
<!-- Nav -->
<div class="nav"></div>
</div>
</div>
Back to index.php the second line we'll add is get_footer(); another Wordpress function to get footer.php.
Currently index.php would look like this now..
<?php get_header(); ?>
</body>
</html>
because everything else is in header.php.. well that closing body and html tag.. those go in footer.php. so your index.php file is going to end up looking like this
<?php get_header();
get_footer(); ?>
Header.php is going to look like this:
<!DOCTYPE>
<html <?php language_attributes(); ?>>
<head>
<!-- Page title / meta -->
<title><?php wp_title( '|', true, 'right' ); ?></title>
<?php wp_head(); ?>
</head>
<body>
<!-- Page container -->
<div id="wrapper">
<div id="main">
<!-- Nav -->
<?php wp_nav_menu(); ?>
</div>
</div>
and you know what's in footer.php. As far as those CSS and javascript files, those are going to be in your functions.php file.
Wordpress has LOTS and LOTS of prefab functions that they like for you to use and it would take forever to explain them all. Luckily a lot of that's already been done in the Wordpress Codex. Though it's got a lot to be desired as far as the quality of the documentation in some places in my opinion it is something you should spend a good amount of time reading thru before you start, in order to familiarize yourself with all their functions.

Resources