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
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>
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>
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>';
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>