php echoing <div> in wrong place - php

i am working on an an options panel for a wordpress theme. this problem has started since i tried trying to add jquery, but it doesn't seem like it should be a jquery problem.. and doesn't go away when i delete all my jquery scripts.
anyway PHP determines whether the page was saved, reset, etc and displays an appropriate message at the top of the page. but for some reason, my div (Which ought to appear first) is appearing after my h2 in the #info div that is several lines below. it isn't a css abs positioning issue as when i view source the #message div is contained w/in #info even though it appears first in the and as far as i can tell all my div tags are opened and closed correctly. this behavior resolves if i get rid of the 'updated' class. i don't desperately need to maintain that class (i can just create a new one w/ similar attributes) but i am baffled as to why the heck the php is firing incorrectly.
<?php
if ($_REQUEST['saved']) {
echo '<div id="message" class="updated fade"><p><strong>' . $my_themename . ' ' . __('settings saved.', 'thematic') . '</strong></p></div>';
}
if ($_REQUEST['reset']) {
echo '<div id="message" class="updated fade"><p><strong>' . $my_themename . ' ' . __('settings reset.', 'thematic') . '</strong></p></div>';
}
if ($_REQUEST['reset_widgets']) {
echo '<div id="message" class="updated fade"><p><strong>' . $my_themename . ' ' . __('widgets reset.', 'thematic') . '</strong></p></div>';
}
if ($_REQUEST['error']) {
echo '<div id="message" class="updated fade"><p><strong>The file you submitted was not a valid image type.</strong></p></div>';
}
if ($_REQUEST['imgremoved']) {
echo '<div id="message" class="updated fade"><p><strong>'. __('Image Removed') .'</strong></p></div>';
}
if ($_REQUEST['imgsaved']) {
echo '<div id="message" class="updated fade"><p><strong>'. __('Image Uploaded') .'</strong></p></div>';
}
?>
<div id="saved"></div>
<div id="header" class="clearfix">
<div id="themelogo"><img src="<?php echo CHILDTHEME_URI .'/functions/css/images/logo.png';?> " / ></div>
<div id="info">
<h1><?php echo $my_themename; ?></h1>
<h2>Built on the Thematic Theme Framework</h2>
</div>
</div>

Not really a solution for the reported behaviour, but noticed a small section of code which may be better expressed differently:
<div id="themelogo"><img src="<?php echo CHILDTHEME_URI .'/functions/css/images/logo.png';?> " / ></div>
Might be better as:
<div id="themelogo"><img src="<?php echo CHILDTHEME_URI; ?>'/functions/css/images/logo.png" /></div>
Just one of those things - I am used to debugging code by reading it and trying to optimise it as I go. I presume the affected file is not available anywhere online for us to review and see the error for ourselves?

One thing that might be worth looking into is whether you are including css files from the jqueryui library. I know I have on several occasions experienced formatting issues when including that css.

Related

Grid/Layout using Bootstrap PHP and CSS

Basically I'm making cooking website and I automised displaying recipes with PHP and HTML.
I'm currently doing some front-end by using Bootstrap but I'm unable to do any decent grid where recipes will look neat and tidy. Also at some point bootstrap is not helping me with grind as I tried to pin up some griding bootstrap with it and css.
As it's automised I'm unable to sort it out and assign to particular column :(
Any help or suggestions will be very much appreciated!
I'm providing my code below
If someone would like to copy
class RecipeLayout {
private static $categories=null;
public static function display($recipe){
//part of code based on which user is being transfered to the other page with full details of the recipe
echo '<div class="card" style="width: 18rem;">';
echo "<img class='main_pg_recipe_img card-img-top'src='./public/images/". $recipe['recipe_image']."'/>";
echo ''.$recipe['recipe_title'] .'';
echo '<div class="recipe_home card-body">';
echo '<h6 class="card-title"> Category: '.self::translateCategory($recipe['recipe_type']) .'</h6>';
echo '<h6 class="card-title"> Calories: '.$recipe['recipe_calories'] .'</h6>';
echo '<h6 class="card-title"> Serves: '.$recipe['recipe_serves'] .'</h6>';
echo '</div>';
echo '</div>';
}
code
desirable layout

How to stop text from wrapping around image when using nl2br? overflow:hidden doesn't work here

I am designing a comment frame for a webpage I am working on. Upon using nl2br to ensure line-breaks aren't removed from stuff submitted from the the in the form, the text just wraps around the user image in the comment section (please see image). overflow:hidden doesn't work here. How to handle this?
A screenshot of the comment frame.
<div class="comment_section" style="overflow:hidden";>
<img src="<?php echo $user_obj->getProfilePic();?>" title="<?php echo $posted_by;?>" style="float:left;" height="30">
<b><?php echo $user_obj->getFirstAndLastName();?></b> <?php echo $time_message . "<br>" . nl2br($comment_body);?>
<hr>
</div>

How to customize wordpress portfolio grid to replace attributes output with text of single portfolio?

I am a php newbie but have to resolve the following issue in some way:
In my …portfolio_grid.php I succeeded in understanding that this part:
$output .= '
<a class="classic-portfolio-box normal-type-prt'.$colorize_fx_class.'" href="'.get_permalink($post_id).'" title="'.get_the_title().'"'.$colorize_hover.'></a>
<div class="portfolio-box">
<div class="portfolio-naming">
<h2 class="portfolio-title">'.get_the_title().'</h2>';
if( !empty($on_attributes) ){
$output .= '
<h3 class="portfolio-attributes">'.$on_attributes.'</h3>';
}
$output .= '</div>
</div>
<img src="'.$image[0].'" width="'.$image[1].'" height="'.$image[2].'" alt="'.get_the_title().'" />
';
is responsible for what appears in my portfolio boxes. Now I’d like to change the following detail:
$output .= '
<h3 class="portfolio-attributes">'.$on_attributes.'</h3>';
Instead of the content of the $on_attributes variable I’d like to put out the content of the single portfolios texts field instead. I bet this is possible.
How can I fetch the content of the text field of each single portfolio post and put it out there? I know that somehow the the_content() or get_the_content() function will play a role but how is it to be done exactly? Any help is appreciated!
You already mentioned the answer in your question:
'<h3 class="portfolio-attributes">' . get_the_content() . '</h3>';
This assumes the the "text of a portfolio item" is actually saved as the WP content in your database.
As a side note, I'm not sure why you're concatenating everything as a string in this case...A wonderful thing about PHP is the ability to weave it in with standard HTML:
<h3 class="portfolio-attributes"><?php the_content(); ?></h3>

Link PHP inside an echo tag

I am having a problem with this code
<?php
echo '<div class="post_note2">
<b>'.$lang['RENEW_SUCCESS'].'</b></div><br /><span class="orange"><b>HOME|VIEW AD</b></span>';
}
}?>
for some reason when the VIEW AD link is clicked it doesn't build it properly and still contains the php code in the link rather than the link to the actual ad page. is it an issue with an echo in an echo ?
I'm sure this isn't quite difficult to solve but I have been trying for far to long on my own and cant get it.
Thanks, any help would be great.
You actually had it right in the first part of your string. You can't have and echo statement inside of another echo statement. Use concatenation throughout your string:
<a href="' . $adurl . '"
You have two extra brackets at the end and php text inside your echo.
<?php
echo '
<div class="post_note2">
<b>'.$lang['RENEW_SUCCESS'].'</b>
</div>
<br />
<span class="orange">
<b>
HOME | VIEW AD
</b>
</span>';
?>
All fixed given that $adurl is defined.
This
<?php echo $adurl; ?>
Should be
' . $adurl . '
i.e.
echo '<div class="post_note2"><b>'.$lang['RENEW_SUCCESS'].'</b></div><br /><span class="orange"><b>HOME|<a href="'.$adurl.'>VIEW AD</a></b></span>';

How do I give separate classes to the styling of the month and year in the Wordpress Date function?

I'm in wordpress, trying to format the date output. This is the code I'm using at present:
<div class="date"><?php the_date('M, Y'); ?></div>
It's output looks like this:
MAY, 2010
What I want to do is have the date display like this (The month on top of the year):
MAY
2010
I'm just not familiar enough with PHP to get things working. A simple line break wouldn't quite be sufficient because I want to play with sizing, placement of each separately (month text larger than the year text, both centered, etc.). Separate classes applied to each would be ideal.
mmmm... I did some more searching and, while I still don't know how to get the "the date" function to display multiple lines correctly, using the "the time" function seems to do the same thing without breaking. Here's the code I'm using. Works great.
<div class="month"><?php the_time(M) ?></div><br />
<div class="year"><?php the_time(Y) ?></div>
<div class="date">
<span class='month'><?php the_date('M');?></span>
<span class='year'><?php the_date('Y'); ?></span>
</div>
You can then set the spans to display: block if you want them to each be on their own line:
<style type='text/css'>
.date span { display: block ; }
</style>
Actually, a line break is a good place to begin:
<div class="date"><?php the_date('M'); ?><br /><?php the_date('Y'); ?></div>
And then add additional CSS as needed. For example, if you then add div's, it becomes apparent that the line break can go away, since separate div's will break on their own as long as the display: property on the parent div (#date) is block.
e.g.:
<div class="date"><div style="something-special..."><?php the_date('M'); ?></div><div style="something-else..."><?php the_date('Y'); ?></div></div>
you should be able to just do
<?php the_date('M<b\r>Y')?>
or any other tags making sure you escape the characters listed here
Put this in your themes functions.php and customize with instructions from http://codex.wordpress.org/Formatting_Date_and_Time
// Add date
function post_date() {
$date = explode(",", get_the_time("F,j,Y", "", "", false));
echo '<div class="post-date">';
echo '<div class="container">';
echo '<div class="month">' . $date[0] . '</div>';
echo '<div class="day">' . $date[1] . '</div>';
echo '<div class="year">' . $date[2] . '</div>';
echo '</div>';
echo '</div>';
}
And then use
<?php post_date(); ?>
where you want the date to show up.
<?
$day = get_the_date('j');
$mnth = get_the_date('M');
?>
<div class="cor-date">
<p><?php echo $day; ?><br><?php echo $mnth; ?></p>
</div>

Categories