I created a notification area for my application. And I would like to display a small red bullet on the right of each tab.
I worked with a position absolute, the thing is now the bullets appear on all the page.
Here is my code and my CSS:
.read-button{
font-size: 8px;
color: #FC5D5D;
display:block;
position:absolute;
right:20px;
padding-top: 15px;
}
And my PHP:
<?php foreach($messages as $mess) { ?>
<?php
$from_user = $user->isClient()?User::findIdentity($mess->message_filmmaker_id):User::findIdentity($mess->message_client_id);
$from_name = $from_user->first_name." ".$from_user->last_name;
$url = "#";
if ($user->isClient()) $url = Url::to(['client/view-project', 'project_id' => $mess->project_id, 'filmmaker_id' => $from_user->id]);
elseif ($user->isFilmmaker()) $url = Url::to(['filmmaker/view-project', 'project_id' => $mess->project_id]);
?>
<a class="content" href="<?= $url ?>">
<div class="notification-item">
<div class="item-pic float-left"><div class="avatar"><?= Html::img(['/site/get-avatar', 'user_id' => $from_user->id]) ?></div></div>
<div class="item-info float-left">
<div><?= $from_name ?> - Il y a <?= $mess->getElapsedTime() ?></div>
<div><?= $mess->message_text ?></div>
</div>
<div class="read-button float-right">
<span class="glyphicon glyphicon-cd" aria-hidden="true"></span>
</div>
<div class="clear-both"></div>
</div>
</a>
<li class="divider"></li>
<?php } ?>
Absolute position works with a parent with absolute or relative position.
Try to set position:relative to notification-item class and absolute position works relative to this parent element.
Related
i'm developing a real estate page, you can check it out here. As you can see, the page take some time to load, because it loads all the 50 apartments/houses at once.
To speed up the page, i want to know if there is any way to delay the load, so the page load faster.
Here is the loop code, i'm wondering what could work, for example if i put some "if/else" condition before the wordpress make a loop (while ( $newsLoop->have_posts() ) : $newsLoop->the_post();?>), but i don't know how to do it. The ideal for me is that the contents are loaded 3 on 3, or "row by row", once a row have 3 apartments.
<div class="portfolio-items2">
<?php
$newsArgs = array(
'post_type' => 'property',
"orderby" => 'meta_value_num',
"meta_key" => 'numerooff',
"order" => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'property-status',
'field' => 'slug',
'terms' => 'oneoff',
)
)
);
$newsLoop = new WP_Query( $newsArgs );
while ( $newsLoop->have_posts() ) : $newsLoop->the_post();?>
<div class="col-md-4 shortcode-col listing_wrapper <?php meta('seletoroff');?>" >
<div class="property_listing" data-link="http://www.onecia.com.br/imoveis-de-luxo/<?php /* Property ID if exists */ $property_id = get_post_meta($post->ID, 'REAL_HOMES_property_id', true); if(!empty($property_id)){ echo ''.$property_id; }?>">
<div class="listing-unit-img-wrapper">
<div class="property_media"> </div>
<a href="http://www.onecia.com.br/imoveis-de-luxo/<?php /* Property ID if exists */ $property_id = get_post_meta($post->ID, 'REAL_HOMES_property_id', true); if(!empty($property_id)){ echo ''.$property_id; }?>">
<img width="525" height="350" src="<?php meta('imagemoff');?>" class="lazyload img-responsive wp-post-image" alt="" sizes="(max-width: 525px) 100vw, 525px" />
</a>
<div class="tag-wrapper"><div class="featured_div"><?php meta('porcentooff');?></div></div>
</div>
<h4>
<a href="http://www.onecia.com.br/imoveis-de-luxo/<?php /* Property ID if exists */ $property_id = get_post_meta($post->ID,'REAL_HOMES_property_id', true); if(!empty($property_id)){ echo ''.$property_id; }?>">
<?php meta('titulooff');?>
</a>
</h4>
<div class="property_location_image">
<a href="http://www.onecia.com.br/imoveis-de-luxo/<?php /* Property ID if exists */ $property_id = get_post_meta($post->ID,'REAL_HOMES_property_id', true); if(!empty($property_id)){ echo ''.$property_id; }?>" rel="tag">
<span style="font-size: 15px;"><?php meta('bairrooff');?> </span>
</a>
</div>
<br>
<div class="property_listing_details">
<?php
$post_meta_data = get_post_custom($post->ID);
if( !empty($post_meta_data['REAL_HOMES_property_size'][0]) ) {
$prop_size = $post_meta_data['REAL_HOMES_property_size'][0];
echo '<div class="inforoom">'. $prop_size .'m² <div class="info_labels"><img src="http://www.onecia.com.br/wp-content/themes/site2016/images/icon-size.png" style="max-width: 14%; height: auto;"></div></div>';
}
if( !empty($post_meta_data['REAL_HOMES_property_bedrooms'][0]) ) {
$prop_bedrooms = floatval($post_meta_data['REAL_HOMES_property_bedrooms'][0]);
$bedrooms_label = ($prop_bedrooms > 1)? __('Bedrooms','framework' ): __('Bedroom','framework');
echo '<div class="infobath">'. $prop_bedrooms .'<div class="info_labels"><img src="http://www.onecia.com.br/wp-content/themes/site2016/images/icon-bed.png" style="max-width: 17%; height: auto;"></div></div>';
}
if( !empty($post_meta_data['REAL_HOMES_property_bathrooms'][0]) ) {
$prop_bathrooms = floatval($post_meta_data['REAL_HOMES_property_bathrooms'][0]);
$bathrooms_label = ($prop_bathrooms > 1)?__('Bathrooms','framework' ): __('Bathroom','framework');
echo '<div class="infosize">'. $prop_bathrooms .'<div class="info_labels"><img src="http://www.onecia.com.br/wp-content/themes/site2016/images/icon-bath.png" style="max-width: 17%; height: auto;">
</div></div>';
}
?>
</div>
<div class="listing_unit_price_wrapper">
<span class="price_label price_label_before" style="text-decoration: line-through;">De: R$ <?php meta('valordeoff');?></span><br>
<span style="text-decoration: underline; font-size: 22px; font-weight: bold;">Por: R$ <?php meta('valoroff');?> </span>
<span class="price_label"></span>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
I've already installed some plugins, but none of them worked.
i have some items i want displayed in the view, my per page is set to 15, so each page displays 15 items, but i want to display ads in the middle of the loop, after maybe 4 items displayed, I've tried to put an if statement in the foreach loop to control the display, it displays the first 3 values, but when i put the div for the ad, it loops too, can someone please tell me what to do, or point me in the right direction?? thanks, here is my code so far:
<?php
$counter1 = 0;
//the foreach loop that retrieves the values from the controller
foreach($records as $record){
//an if statement to display the first 4 items..
if ($counter1 <= 3){
?>
<div class='box-scene'>
<div class='dbox'>
<div class='front face'>
<img src="images/newtag.png">
</div>
<a style="font-size:15px;" href="<?php echo base_url();?>music/<?php echo $record->url; ?>">
<div class="side face">
<span>
<?php echo $record->name; ?>
</span>
</div>
</a>
</div>
</div>
<?php
$counter1++;
}
?>
<div style="width:200px; height:200px; float:left; display:inline-block; margin: 0 12.5px 20px 12.5px;">
<div id="ad_200_200">
</div>
</div>
<!-- this div displays more than once, i dont know where to place it
for it to display after the first 3 items -->
<?php
}
?>
i want to know where to place the div, and how to continue displaying the items...thanks
Hi please use else condition.please check replace with below code
<?php
$counter1 = 0;
//the foreach loop that retrieves the values from the controller
foreach ($records as $record) {
//an if statement to display the first 4 items..
?>
<?php if($counter1 % 4 == 0) { ?>
<div style="width:200px; height:200px; float:left; display:inline-block; margin: 0 12.5px 20px 12.5px;">
<div id="ad_200_200">
</div>
</div>
<?php } ?>
<div class='box-scene'>
<div class='dbox'>
<div class='front face'>
<img src="images/newtag.png">
</div>
<a style="font-size:15px;" href="<?php echo base_url(); ?>music/<?php echo $record->url; ?>">
<div class="side face">
<span>
<?php echo $record->name; ?>
</span>
</div>
</a>
</div>
</div>
<!-- this div displays more than once, i dont know where to place it
for it to display after the first 3 items -->
<?php
$counter1++;
}
?>
use also an else statement like below:
<?php
$counter1 = 0;
foreach($records as $record){
if ($counter1 <= 3){ ?>
<div class='box-scene'>
<div class='dbox'>
<div class='front face'>
<img src="images/newtag.png">
</div>
<a style="font-size:15px;" href="<?php echo base_url();?>music/<?php echo $record->url; ?>">
<div class="side face">
<span>
<?php echo $record->name; ?>
</span>
</div>
</a>
</div>
<div>
<?php
$counter1++;
} else{ ?>
<div style="width:200px;height:200px;float:left;display:inline-block; margin: 0 12.5px 20px 12.5px;">
<div id="ad_200_200"></div>
</div>
<?php
$counter1 = 0;
} ?>
<?php
}
?>
This question already has answers here:
Grid of responsive squares
(5 answers)
Closed 3 years ago.
I'm making a theme for my Omeka site in which I am calling an item and its various components using PHP. Each item is in its own div, and I have attempted to create a tile-like grid with Bootstrap. However, the divs only line up in a single vertical column. How do I make all divs line up in a row of three or four? I'm completely stumped. It works fine without the PHP (with multiple rows and manually added content) but won't work otherwise. This is what it looks like right now. And this is what I want the divs to look like:
Here is the html/php:
<?php foreach (loop('items') as $item): ?>
<div class="container">
<div class="item">
<div class="row">
<!-- attempt at square grid -->
<div class="col-md-3 col-sm-4 col-xs-6 item-item">
<div class="dummy"></div>
<div class="thumbnail purple">
Image: <?php $image = $item->Files; ?>
<?php if ($image) {
echo link_to_item('<div style="background-image: url(' . file_display_url($image[0], 'original') . ');" class="img"></div>');
} else {
echo link_to_item('<div style="background-image: url(' . img('defaultImage#2x.jpg') . ');" class="img"></div>');
}
?>
Title: <?php echo link_to_item(metadata('item', array('Dublin Core', 'Title')), array('class'=>'permalink')); ?><br>
Creator: <?php echo metadata('item', array('Dublin Core', 'Creator')); ?><br>
Subject: <?php echo metadata('item', array('Dublin Core', 'Subject')); ?><br>
Description: <?php echo metadata('item', array('Dublin Core', 'Description'), array('snippet'=>150)); ?><br>
<br>
</div>
</div>
</div>
</div><!-- end grid -->
And the CSS:
.dummy {
margin-top: 100%;
}
.thumbnail {
position: absolute;
top: 15px;
bottom: 0;
left: 15px;
right: 0;
text-align:center;
padding-top:calc(50% - 30px);
}
.item-item {
border: solid black 5px;
}
I'll give you a pseudo method of achieving this, harnessing array_chunk().
$chunks = array_chunk($array, 4);
foreach($chunks as $group): ?>
<div class="row">
<?php foreach($group as $element): ?>
<div class="col-md-3 col-sm-4 col-xs-6 item-item">
<?php // do your php stuff...?>
</div>
<?php endforeach; ?>
</div>
<?php endforeach; ?>
Example
I'm creating a static block to show the subcategories of a category in Magento. The code is made by me and with some ideas taken in the web.
The idea is to show a title with plain background called back.png as thumbnail of the subcategory when this one hasn't a thumbnail or the category thumbnail if the image is uploaded. For the moment I can't show the thumbnails, could anybody help me?
Thanks.
<div class="product_list" style="width:900px;">
<?php $_helper = Mage::helper('catalog/category') ?>
<?php $currentCategory = Mage::registry('current_category') ?>
<?php if($currentCategory->children_count > 0) { ?>
<?php
$cat = Mage::getModel('catalog/category')->load($currentCategory->entity_id);
$_categories = $cat->getChildrenCategories();
?>
<?php if (count($_categories) > 0): ?>
<ul>
<?php foreach($_categories as $_category): //print_r($_category); ?>
<?php
$imageUrl = Mage::getModel('catalog/category')->load($_category->getId())->getThumbnailUrl();
$imageName = substr(strrchr($imageUrl,"/"),1);
$imagePrefx = Mage::getBaseUrl('media')."catalog/category/";
$newImageUrl2 = $imagePrefx.$imageName;
?><div clas="subcat-el">
<li style="float:left; margin-right:10px;">
<div class="subcat-name" style="z-index:20; width:270px; position:absolute; margin-top:134px;text-align: center;">
<a href="<?php echo $_helper->getCategoryUrl($_category) ?>" style="text-decoration:none;">
<h3 style="margin-left:18px; font-family:Helvetica; font-weight:200;text-shadow: 1px 1px 1px #030;font-size: 24px;color:#fff; ">
<?php echo $_category->getName() ?>
</h3>
</a>
</div>
<div style="width:270px; height:270px;background: #fff;
border: 9px solid #fff; border-radius: 3px;-webkit-border-radius: 3px;-moz-border-radius: 3px;-webkit-box-shadow: 0 0 6px 0 rgba(0,0,0,0.15);-moz-box-shadow: 0 0 6px 0 rgba(0,0,0,0.15);box-shadow: 0 0 6px 0 rgba(0,0,0,0.15);margin-bottom:10px;">
<a href="<?php echo $_helper->getCategoryUrl($_category) ?>">
<img src="<?php
if ($newImageUrl2 == $imagePrefx): $newImageUrl2 = Mage::getBaseUrl('skin')."/subcat/back.png";
endif;
echo $newImageUrl2; ?>" alt="<?php echo $_category->getName() ?>" style="width:100%;">
</a>
</div>
</li>
</div>
<?php endforeach; ?>
</ul>
<br style="clear:left;" />
<?php endif; ?>
<?php } else { echo "<h3>No Sub-category found</h3>"; } ?>
</div>
There is no such method by default as in your line:
Mage::getModel('catalog/category')->load($_category->getId())->getThumbnailUrl();
you should try getThumbnail() instead
Or you could try smth like this
$imageUrl = Mage::getBaseUrl('media') . 'catalog/category/' . $_category->getThumbnail()
Or you can try to specify your own method getThumbnailUrl in your own extension
public function getThumbnailUrl(Mage_Catalog_Model_Category $category)
{
return (bool)$category->getThumbnail()
? Mage::getBaseUrl('media') . 'catalog/category/' . $category->getThumbnail()
: '';
}
EDIT 01-28-13: Revised to clarify my question.
I'm using Magento 1.7.0.0 and FishPig WP full integration. We have successfully listed products from specific category and from all categories but was wondering if we can exclude in some cases from specified category. I found solutions to do this in functions.php within WordPress but this does not seem to work.
Here is the current code that displays posts from all categories. We'd like to add an exception so WordPress 1 Category can be excluded.
Here is the code that displays from all categories which I'd like to NOT include category "Press_HomePage":
$col_posts = Mage::getResourceModel('wordpress/post_collection')->addIsPublishedFilter();
$posttotal = count($col_posts->getAllIds());
$posttotid = $col_posts->getAllIds();
//i<=2 means displays last 2 posts
//display latest 2 posts...
for ( $i=1; $i<=2; $i++ )
{
?>
<div class="blog">
<h2><?php echo $col_posts->getItemById($posttotid[$posttotal-$i])->getPostDate(); ?></h2>
<h1><?php echo $col_posts->getItemById($posttotid[$posttotal-$i])->getPostTitle(); ?></h1>
<div style="float:left; margin-top:15px; margin-bottom:25px;">
<?php
$featured_img = $this->getSkinUrl('images/pree_emty.png');
if($featuredImage = $col_posts->getItemById($posttotid[$posttotal-$i])->getFeaturedImage())
{
$featured_img = $featuredImage->getAvailableImage();
}
?>
<img style="float: left;" src="<?php echo $featured_img; ?>" width="204" height="204" alt="" />
<div style="float: left; width: 580px; padding: 10px;">
<p><?php echo substr(strip_tags($col_posts->getItemById($posttotid[$posttotal-$i])->getPostContent()), 0, 400); ?></p>
<p>
<a href="<?php echo $col_posts->getItemById($posttotid[$posttotal-$i])->getUrl(); ?>">
<img src="<?php echo $this->getSkinUrl('images/view_btn.jpg'); ?>" width="170" height="32" alt="" />
</a>
</p>
</div>
</div>
</div>
<?php
}
?>
Let me know if I need to clarify myself. I appreciate your time.
//loki - get all the post ids
$col_posts = Mage::getResourceModel('wordpress/post_collection')->addIsPublishedFilter();
$posttotid = $col_posts->getAllIds();
//loki - get all the press ids
$col_posts_press = Mage::getResourceModel('wordpress/post_collection')->addIsPublishedFilter()->addCategorySlugFilter('press_homepage');
$posttotid_press = $col_posts_press->getAllIds();
//loki - removing the press_homepage category from array and reindexing
$blogposts = array_diff($posttotid, $posttotid_press);
$blogposts = array_values($blogposts);
$posttotal = count($blogposts);
//i<=2 means displays last 2 posts
//display latest 2 posts...
for ( $i=1; $i<=2; $i++ )
{
?>
<div class="blog">
<h2><?php echo $col_posts->getItemById($blogposts[$posttotal-$i])->getPostDate(); ?></h2>
<h1><?php echo $col_posts->getItemById($blogposts[$posttotal-$i])->getPostTitle(); ?></h1>
<div style="float:left; margin-top:15px; margin-bottom:25px;">
<?php
$featured_img = $this->getSkinUrl('images/pree_emty.png');
if($featuredImage = $col_posts->getItemById($blogposts[$posttotal-$i])->getFeaturedImage())
{
$featured_img = $featuredImage->getAvailableImage();
}
?>
<img style="float: left;" src="<?php echo $featured_img; ?>" width="204" height="204" alt="" />
<div style="float: left; width: 580px; padding: 10px;">
<p><?php echo substr(strip_tags($col_posts->getItemById($blogposts[$posttotal-$i])->getPostContent()), 0, 400); ?></p>
<p>
<a href="<?php echo $col_posts->getItemById($blogposts[$posttotal-$i])->getUrl(); ?>">
<img src="<?php echo $this->getSkinUrl('images/view_btn.jpg'); ?>" width="170" height="32" alt="" />
</a>
</p>
</div>
</div>
</div>
<?php
}
?>