I've got a php echo which I'm using to echo out image banners on a zen cart based system.
<hgroup id="cat_banner" style="background-image:url(images/categories/banners<?php echo"/"; echo strtolower(str_replace('&','and',str_replace(' ','_',$breadcrumb->last()))); ?>_banner.jpg);">
<h1 id="productListHeading"><?php echo $breadcrumb->last(); ?></h1>
<?php
// categories_description
if ($current_categories_description != '') {
?>
<p id="indexProductListCatDescription" class="content"><?php echo $current_categories_description; ?></p>
<?php } // categories_description ?>
it is not showing the / on some images but is showing it on others and displaying the image.
$path = strtolower(str_replace('&','and',str_replace(' ','_',$breadcrumb->last())));
<hgroup id="cat_banner" style="background-image:url("images/categories/banners/".$path."_banner.jpg)>
Related
I've created custom post type as single-service.php and I have several custom taxonomies under service posts like education, recruit and health.
I currently created some queries and under each query, I want to create a button which direct the users the contact form page of that service. It is like when you get into a single service page which is categorized under education there will a button directs them to education contact form page likewise for recruit page.
I have tried below link but somehow it does not work. I am not sure whether I am using correct code or where do I make mistake
<?php if (in_category( 'education', $post->ID )) : ?>
<?php echo '<div class="button">Contact us</div>'; ?>
<?php elseif (in_category('recruit', $post->ID)) :?>
<?php echo '<div class="button">Contact us</div>'; ?>
<?php elseif (in_category('health', $post->ID)) :?>
<?php echo '<div class="button">Contact us</div>'; ?>
<?php endif;?>
I solve my problem by creating two custom fields in the template page and linking them with :
<div class="service-button">
<?php $info = get_post_meta(get_the_ID(), '_post_info', true); if (!$info) $info = array(); ?>
<a class="form" style="background-color:<?php echo $info['color'] ?>" href="<?php echo $info['form'] ?>">Contact us</a>
<?php if ($info['website']) : ?>
<a class="website" style="background-color:<?php echo $info['color'] ?>" href="http://<?php echo $info['website'] ?>"><?php echo $info['website'] ?></a>
<?php endif; ?>
</div>
I'm having an issue with open cart(v2.0.3.1) and the journal template (v2.4.9).
The issue: when I add a journal module like the Carousel, Banners etc. and try to place the module in the content section (either column_right, column_left or content_top, content_bottom) it won't show up on the site (not only home but all other pages aswell) However if I cange the position to "top" or "bottom" it does show up!
I've checked the file catalog/view/theme/journal2/template/common/home.tpl
to check if the columns are printed and saw this:
<div id="container" class="container j-container"><div class="row"><?php echo $column_left; ?> <?php echo $column_right; ?>
<?php if ($column_left && $column_right) { ?>
<?php $class = 'col-sm-6'; ?>
<?php } elseif ($column_left || $column_right) { ?>
<?php $class = 'col-sm-9'; ?>
<?php } else { ?>
<?php $class = 'col-sm-12'; ?>
<?php } ?>
<div id="content" class="<?php echo $class; ?>"><?php echo $content_top; ?><?php echo $content_bottom; ?></div>
</div>
So they seem to be echoed however they don't show up on the website.
Actualy they do show up but only with the opencart elements not the custom elements made by the template.
I could use some help because i've been searching for 2 whole days and I can't seem to find a propper solution.
Need to figure this out for a client.
The problem was in the template after I updated it to a newer version the issue resolved!
how can i solve the following problem. Basically I want to show different sub headings based on the wordpress category being used.
this is the following code:
$categ = the_category(' ');
if($categ == 'News'){
$second_header = " secondry header displayed here";
}else{
$second_header = "Error";
}
?>
<h2> <?php the_category(' '); ?></h2>
<p> <?php echo $second_header; ?></p>
Right now this is not working, instead of checking against the text 'news' is there any way to check against the category id?
thanks in advance.
You can use the following to store the current category id:
<?php $catID = the_category_ID($echo=false);?>
The echo false stops any echo on the page and stores the variable. You can then do the following:
<?php
$categ = the_category_ID($echo=false);
if($categ == 1)
{
$second_header = " secondry header displayed here";
}
else
{
$second_header = "Error";
}
?>
<h2> <?php the_category(' '); ?></h2>
<p> <?php echo $second_header; ?></p>
Alternatively to this you could also use the following (as I believe the_category_ID is now deprecated http://codex.wordpress.org/Function_Reference/the_category_ID):
$categories = get_the_category();
$categ = $categories[0]->cat_ID;
if($categ == 1)
{
$second_header = " secondry header displayed here";
}
else
{
$second_header = "Error";
}
?>
<h2> <?php the_category(' '); ?></h2>
<p> <?php echo $second_header; ?></p>
Different Text on some Category Pages:
<?php if (is_category('Category A')) : ?>
<p>This is the text to describe category A</p>
<?php elseif (is_category('Category B')) : ?>
<p>This is the text to describe category B</p>
<?php else : ?>
<p>This is some generic text to describe all other category pages,
I could be left blank</p>
<?php endif; ?>
if you need category id you will need to first get category through <?php get_the_category_by_ID( $cat_ID ); ?>
Because the_category_ID is deprecated, then you can do the same with some modification.
More here - http://codex.wordpress.org/Category_Templates
I'm trying to change the header logo on my site, depending on the page the person is on. I don't know PHP, but I've found where the Logo is defined in header.php, and am trying to rewrite it to be dynamic. When I use my code, the site breaks, so obviously I'm doing something wrong.
The original code is:
<!-- Logo -->
<?php
// Get the logo
if ($ti_option['site_logo'] != '') {
$site_logo = $ti_option['site_logo'];
}
else {
$site_logo = get_template_directory_uri() . '/images/logo.png';
}
?>
<a class="logo" href="<?php echo home_url('/'); ?>">
<img src="<?php echo $site_logo; ?>" alt="<?php bloginfo('name'); ?>
-
<?php bloginfo('description'); ?>" title="<?php bloginfo('name'); ?>
-
<?php bloginfo('description'); ?>" />
</a>
<!-- End Logo -->
What I'm trying to do is display a different logo based on which page the visitor is on. There are three:
- if the page is one of these: (1168, 1433, 1428), display /path/logo1.jpg
- if the page is one of these: (1369, 1361, 1365), display /path/logo2.jpg
- otherwise, just show /path/logo3.jpg
Here's what I've been able to manage so far:
<!-- Logo -->
<?php
// Get the logo
< ? php
if ($ti_option['site_logo'] != '') {
if (is_page(array(
1168,
1433,
1428
))) :
// '$site_logo' => 'FILELOCATION.jpg',
$site_logo = $ti_option['site_logo'];));
elseif (is_page(array(
1369,
1361,
1365
))):
$site_logo = $ti_option['site_logo'];));
else:
$site_logo = $ti_option['site_logo'];
endif;
?>
} else {
$site_logo = get_template_directory_uri() . '/images/logo.png';
}
?>
<a class="logo" href="<?php echo home_url('/'); ?>">
<img src="<?php echo $site_logo; ?>" alt="<?php bloginfo('name'); ?>
-
<?php bloginfo('description'); ?>" title="<?php bloginfo('name'); ?>
-
<?php bloginfo('description'); ?>" />
</a>
<!-- End Logo -->
I don't think I can nest PHP opening and closing tags, so there's that. But, I feel like I need to... my code doesn't work. Can anyone point me in direction of what to try?
I'm not 100% sure on wordpress standards, but here's a way to do it.
$logo1 = "logo1.jpg";
$logo2 = "logo2.jpg";
if ($ti_option['site_logo'] != '') {
if (is_page(array( 1168, 1433, 1428))){
$site_logo = $logo1;
}else if (is_page(array( 1369, 1361, 1365))){
$site_logo = $logo2;
}else{
$site_logo = $ti_option['site_logo'];
}
?>
} else {
I see 2 issues with your code :
1- No matter the outcome, you end up doing this : $site_logo = $ti_option['site_logo'];
In other words, you never actually change the logo.
2- Might be due to the fact you're using the dots if(cond): instead of if(cond){} which I'm not used to work with but imo it's much clearer when you have a good indentation.
error that is probably making your code crash :
$site_logo = $ti_option['site_logo'];));
should be
$site_logo = $ti_option['site_logo'];
I am trying to implement the jQuery live thumbnails with my PHP page. On the page I am retrieving event information along with a comma separated list of thumbnail values. The plugin works a bit differently that that and I am having difficulty adapting my script to work. The plugin is located here http://tutorialzine.com/2012/12/album-photo-previews-jquery/. In their example they use an array while I have a comma separated list of thumbnails. The code I have so far is here...
<?php foreach ($events as $event) { ?>
<div class="left13 section_home" style="margin-bottom:25px;">
<h2><?php echo $event['event_title']; ?></h2>
<div align="center">
<?php foreach ($event['thumbnails'] as $thumbnail) { ?>
<a href="#" data-images="<?php echo str_replace(',', '|', $event['thumbnails']); ?>" class="album">
<img src="<?php echo ($event['thumbnails'] != '') ? base_url() . 'media/photos/thumbnail/' . $event['thumbnails'] : base_url() . 'images/no_photo_thumbnail.png'; ?>" alt="" title="" /><span class="preloader"></span></a>
<p><?php echo ($event['event_description'] != '') ? substr($event['event_description'], 0, 200) : 'No description yet...'; ?></p>
<span class="swirl_left"><span class="swirl_right">View This Event</span></span>
<?php } ?>
</div>
</div>
<?php } ?>
How would I be able to make this script work by using a comma separated list of thumbnail values instead of the array used in the tutorial? Thanks!
I figured it out and the answer is quite simple. First, my data coming from the database included a comma separated list of thumbnails. I just used the proper functions to insert that data into the script. The only problem I have now is that I need to add the path to the beginning of each value in the comma separated list. Is there a PHP function to do that? Below is my almost finished code.
<div class="content">
<?php foreach ($events as $event) {
// Create an array out of the comma separated list of thumbnails
$thumbnails = explode(',', $event['thumbnails']); ?>
<div class="left13 section_home" style="margin-bottom:25px;">
<h2><?php echo $event['event_title']; ?></h2>
<div align="center">
<img src="<?php echo base_url() . 'media/photos/thumbnail/' . $thumbnails[0]; ?>" alt="" title="" /><span class="preloader"></span>
<p><?php echo ($event['event_description'] != '') ? substr($event['event_description'], 0, 200) : 'No description yet...'; ?></p>
<span class="swirl_left"><span class="swirl_right">View This Event</span></span>
</div>
</div>
<?php } ?>
</div>
To finish this up I need to add the following to the beginning of each item in $event['thumbnails']...
<?php echo base_url(); ?>media/photos/thumbnail/
Then it should work perfectly.