Site template not working in wordpress - php

Okay, so I'm developing a site in wordpress and I have two file templates "Default Template" and "Shop" in both templates I have;
<?php include('breadcrumbs.php'); ?>
and inside the 'breadcrumbs.php' file I the following;
<div class="breadcrumbs">
<div class="container">
<div class="row">
<div class="col-lg-12">
<ol class="breadcrumb">
<?php
if (function_exists('show_full_breadcrumb')) {
show_full_breadcrumb();
}
?>
</ol>
</div>
</div>
</div>
</div>
Now these breadcrumbs display properly if it is in the 'default template' like this;
But on the shop page display like this and I have no idea why as they're both including the same file;
now I'm not sure if this would affect much of it but I am also using WooCommerce.
Hopefully someone can help! thanks in advance!

It's definitely a css issue. Something is overriding the styling on that shop page. Use firebug to diagnose the breadcrumbs. Or provide a link so I can look at it. But Firebug will show you the ul styling right on the breadcrumbs and you can A/B between the default and the shop template. Should be an easy fix with the CSS
Hope this helps.

Related

<!--nextpage--> somehow causes the layout to be skewed

I'm using the <!--nextpage--> function to page break and split the page on Wordpress.
The problem is, whenever <!--nextpage--> is inserted, the position of sidebar is moved to where it shouldn't be.
It's like this on page.php:
<div class="main">
<?php
if (have_posts()) :
...
?>
<?php wp_link_pages(); ?>
</div>
<?php get_sidebar(); ?>
So if I understand correctly, .main and get_sidebar are on the same level.
But when I actually make some page using this template, an output is like this:
<div class="main">
<div class="section">
...
<div class="content">
// pagination is inserted here
</div>
<aside class="sidebar">
...
</aside>
</div>
</div>
In other words, get_sidebar(aside tag) automatically moves into .section.
This is extremely confusing to me, and really don't know what to do here.
Why does Wordpress decide to put it inside of .section? Why can't it be faithful to the template?
Now the sidebar is positioned at the end of content instead of being on the right side.
What are the possible causes and solution to this issue?
Thank you for reading.

Display parent div only if populated with content

Is there a way to only display a parent (wrapping) if it's actually been populated with content?
The reason I ask is in Wordpress I'm using Advanced Custom Fields to create additional text areas on the homepage of the website. The content is added to the page inside divs, like this:
<section class="band">
<div class="wrap">
<?php the_field('services'); ?>
</div>
</section>
If the field is left blank, obviously the markup that surrounds remains on the page and due to the margin/padding they have set on them it leaves a big empty stripe across the page.
I know little Wordpress (and PHP in general), I assume this must be possible? I've had a play around with if/else statements but had no luck.
Can anyone advise on this?
You could do it this way:
<?php if( get_field('services') ) : ?>
<section class="band">
<div class="wrap">
<?php the_field('services'); ?>
</div>
</section>
<?php endif; ?>

QuickApps CMS and menu change in theme

I'm trying to make a new theme for QuickApps CMS. When I try to echo:
<?php echo $this->Block->region('user-menu'); ?>
To render the user-menu in the new theme layout, it do two things:
Print out a title for the menu named "User Menu" while in the
Default theme it does not print this title.
In addition it prints different HTML as follows
My New Theme output
<div id="qa-block-5" class="qa-block qa-block-unique qa-block-menu">
<div id="block_5" class="block block-Menu delta-user-menu ">
<h2> User Menu </h2>
<div class="content">
<ul>
<li id="menu-item-22" class="first-item menu-item-22"><span>My account</span> </li>
<li id="menu-item-23" class="last-item menu-item-23"><span>Logout</span> </li>
</ul>
</div>
</div>
</div>
The Default Theme ouput
<div id="user-menu">
<div id="qa-block-5" class="qa-block qa-block-unique qa-block-menu">
<ul>
<li id="menu-item-22" class="first-item menu-item-22"><span>My account</span> </li>
<li id="menu-item-23" class="last-item menu-item-23"><span>Logout</span> </li>
</ul>
</div> </div>
I tried to find any elements that handles this HTML but I could not find. What I need to know is how to change the output of the menu according to my new theme? i.e change its HTML structure including styles class names.
If you need to customize the output, your theme can implement the "theme_block" view element,
it will be used when rendering each block.
Here you can see "Default Theme" implementation:
https://github.com/QuickAppsCMS/QuickApps-CMS/blob/1.1/QuickApps/View/Themed/Default/Elements/theme_block.ctp
QuickApps uses a series of view elements for when rendering, if your theme do not implement any of this core's element are used by default. Here you can see a list of elements your theme may implement:
https://github.com/QuickAppsCMS/QuickApps-CMS-Docs/blob/1.x/eng/designers/themes.md#rendering-elements
Best regards!
/Chris
PS: BTW, there are big changes coming in v2.0 so stay tuned. For example blocks & regions are now objects, you can now do nifty things, for instance:
$this->region('main-menu')
->merge($this->region('other-region'))
->blockLimit(5);

Cakephp, adding a view to a sidebar

I'm struggling trying to understand cakephp's views, blocks and layouts.
I need everypage to show a left and right sidebar which content might change. At this moment I have the right sidebar defined in /pages/home.ctp but I'm guessing it would be better to extend that sidebar since it has to appear in everypage. Correct me if that thought is wrong.
Then, I have this view add.ctp for the 'usuarios' table, it practically shows the fields login and password. I want to show this view in the sidebar, but I'm really lost as how to do that.
Thanks in advance.
Lets make this thing easy. Like #patrick said, there is a lots of way.
Start with layout file. Rearrange your default.ctp layout like-
default.ctp layout
<div id="container">
<div id="header">
<?php echo $this->element('header');?>
</div>
<div id="left-sidebar">
<?php echo $this->element('left-sidebar');?>
</div>
<div id="content">
<?php echo $this->Session->flash(); ?>
<?php echo $this->fetch('content'); ?>
</div>
<div id="right-sidebar">
<?php echo $this->element('right-sidebar');?>
</div>
<div id="footer">
<?php echo $this->element('footer');?>
</div>
</div>
Now create elements ctp files as header.ctp, left-sidebar.ctp, right-sidebar.ctp and so on and place them to app/View/Elements.
Your left-sidebar.ctp file may looks like this...
left-sidebar.ctp
// to show login form //
if you just need to show on view.ctp place few logic here for login form.
//end login form//
show other sidebar contents
There are a couple ways to do it, depending on your Cake version. If you're using >=2.1 (which I assume you are since you asked about blocks), then you should try those to see if they work for your setup. The way I usually do things is that if all views for a controller need common markup then those view files would extend a base view within the Controller directory, e.g.
#/View/Posts/index.ctp
<?php
$this->extend('_skel'); //arbitrary filename, I use '_skel' since that makes sense
echo $this->Html->para(null, 'Hello');
#/View/Posts/_skel.ctp
<?php
echo $this->Html->div('sidebar', 'Sidebar for posts...');
echo $this->fetch('content'); // This gets all output from the Posts/index.ctp view
Then all your Posts views which extend _skel will have the sidebar automatically.
Your login module might make sense as an element - something that could be used anywhere in your views.

Editing certain parts of page template in User mode

I have a web page I am working on in WP which needs some customization.
Firstly I have created a page template that will be used over and over again, only changing parts of the content. I am wondering about available options for me when enabling this fact, through the Admin panel in the HTML Editor(if possible)...
Hope my question is clear enough for you all.
Let me add some code to show what I am trying to accomplish.
<div id="header-style">
<?php get_header();?>
</div>
<div id="content">
<div id="about">
//This is what i want to be able to edit
</div>
<div id="features">
//This is what i want to be able to edit
</div>
</div>
Dino:
There are lots of ways you could do this. The main question I would ask you is, who is going to be adding/editing this content? If you're going to have a community of people adding content, the input needs to be stripped and sanitized (to avoid injecting tags or other harmful content). If its just going to be you, then here's the easiest/fastest solution:
Use custom fields. If you can't see them in the post/page edit screen, go to the little tab on the top right of the post-edit screen that says Screen Options (or something like that) and click "Custom Fields".
Once you can see the Custom Fields edit box, you can add as many fields as you want. These are stored as post meta data. You can use the <?php the_meta(); ?> function in the loop to display all of your custom fields.
You can access a specific field by using get_post_meta(). You pass in the postID and the key of the meta field:
<?php echo get_post_meta(get_the_ID(), 'my_key'); ?>
So, for your example, you would add in the post-edit screen:
about: Some text to go in the about section.
features: Some text to go in the features section.
Then, you would access these on your page like so:
<div id="header-style">
<?php get_header();?>
</div>
<div id="content">
<div id="about">
<?php echo get_post_meta(get_the_ID(), 'about'); ?>
</div>
<div id="features">
<?php echo get_post_meta(get_the_ID(), 'features'); ?>
</div>
</div>

Categories