Wordpress noob here, After searching for two days without any success!, i'm trying to display a difference color in the front end for each selected option from menu.
I used this code for creating menu inside users profile
<table class="form-table">
<tr>
<th><label for="dropdown">Job Stats</label></th>
<td>
<?php
//get dropdown saved value
$selected = get_the_author_meta( 'user_job_stats', $user->ID ); //there was an extra ) here that was not needed
?>
<select name="user_job_stats" id="user_job_stats">
<option class="available" value="available" <?php echo ($selected == "available")? 'selected="selected"' : '' ?>>Available</option>
<option class="busy" value="busy" <?php echo ($selected == "busy")? 'selected="selected"' : '' ?>>Busy</option>
</select>
<span class="description">Select Stats.</span>
</td>
</tr>
</table>
And i used this code for displaying them in the front end
<div class="job-stats">
<?php if (!empty(get_the_author_meta('user_job_stats', $curauth->ID))) { ?>
<dt><?php echo $curauth->user_job_stats; ?></dt>
<?php } ?>
</div>
What i'm trying to do is when users selected an option ex:Busy
I want to make the background color of the option " Busy" to be red IN FRONT END
And with option "Available" background color to be green IN FRONT END.
Any help please?
use CSS's pseudo class to style the relevant tags.
<style>
.available:checked { background: green; }
.busy:checked { background: red; }
</style>
<table class="form-table">
<tr>
<th><label for="dropdown">Job Stats</label></th>
<td>
<?php
//get dropdown saved value
$selected = get_the_author_meta( 'user_job_stats', $user->ID ); //there was an extra ) here that was not needed
?>
<select name="user_job_stats" id="user_job_stats">
<option class="available" value="available" <?php echo ($selected == "available")? 'selected="selected"' : '' ?>>Available</option>
<option class="busy" value="busy" <?php echo ($selected == "busy")? 'selected="selected"' : '' ?>>Busy</option>
</select>
<span class="description">Select Stats.</span>
</td>
</tr>
</table>
and for the front-end:
<style>
dt.available { background: green; }
dt.busy { background: red; }
</style>
<div class="job-stats">
<?php if (!empty(get_the_author_meta('user_job_stats', $curauth->ID))) { ?>
<dt class="<?php echo $curauth->user_job_stats ?>"><?php echo $curauth->user_job_stats; ?></dt>
<?php } ?>
</div>
Related
Having actual Magento 1.9.3 situation...
In product-page there are a lot of configuration options. Need to save space, so need to turn the one column vertical product options list into a two column list to reduce the space to 50%.
Already tried several methods, also this one:
https://magento.stackexchange.com/questions/70857/display-product-options-change-layout-of-in-block-after-info-column
in combination with
Css Styling list elements in two columns
and this
https://csswizardry.com/2010/02/mutiple-column-lists-using-one-ul/
But did not figure it out really. Was stopping on the results, to display all in only one horizontal line. The issue is, that if there are 10 attributes to select, the line is becoming very pressed and nothing is recognisable.
Is anyone out there, who is able to adjust the code?
Here is the code having in:
/template/catalog/product/view/type/options/configurable.phtml
<?php
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
$_jsonConfig = $this->getJsonConfig();
$_renderers = $this->getChild('attr_renderers')->getSortedChildren();
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<div class="items">
<dl>
<?php foreach($_attributes as $_attribute): ?>
<?php
$_rendered = false;
foreach ($_renderers as $_rendererName):
$_renderer = $this->getChild('attr_renderers')->getChild($_rendererName);
if (method_exists($_renderer, 'shouldRender') && $_renderer->shouldRender($_attribute, $_jsonConfig)):
$_renderer->setProduct($_product);
$_renderer->setAttributeObj($_attribute);
echo $_renderer->toHtml();
$_rendered = true;
break;
endif;
endforeach;
if (!$_rendered):
?>
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
<option><?php echo $this->__('Choose an Option...') ?></option>
</select>
</div>
</dd>
<?php endif; ?>
<?php endforeach; ?>
</dl>
</div>
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $_jsonConfig ?>);
</script>
<?php echo $this->getChildHtml('after') ?>
<?php endif;?>
Without Seeing the output its hard to know what you want exactly, but if you want the options to be in 2 columns this should work.
.items dl {
display:flex;
flex-wrap: wrap;
}
.items dl .options-wrapper{
width: 50%;
}
//If you want on smaller screens to make them 1 row.
#media screen and (max-width: 768px) {
.items dl .options-wrapper{
width: 100%;
}
}
<?php
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
$_jsonConfig = $this->getJsonConfig();
$_renderers = $this->getChild('attr_renderers')->getSortedChildren();
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<div class="items">
<dl>
<?php foreach($_attributes as $_attribute): ?>
<?php
$_rendered = false;
foreach ($_renderers as $_rendererName):
$_renderer = $this->getChild('attr_renderers')->getChild($_rendererName);
if (method_exists($_renderer, 'shouldRender') && $_renderer->shouldRender($_attribute, $_jsonConfig)):
$_renderer->setProduct($_product);
$_renderer->setAttributeObj($_attribute);
echo $_renderer->toHtml();
$_rendered = true;
break;
endif;
endforeach;
if (!$_rendered):
?>
<div class="options-wrapper">
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
<option><?php echo $this->__('Choose an Option...') ?></option>
</select>
</div>
</dd>
</div>
<?php endif; ?>
<?php endforeach; ?>
</dl>
</div>
<script type="text/javascript">
var spConfig = new Product.Config(<?php echo $_jsonConfig ?>);
</script>
<?php echo $this->getChildHtml('after') ?>
<?php endif;?>
Hey guys ok so i'm wokring on a clients Weekly Newsletter i'm working with Joomla 2.5.19 and using the enterprise version of acymailling to send it out. I'm kicking my heading in at the moment because of outlook, i'm using a module from Jreviews that publishes the latest reviews submitted to the site in the newsletter, it all works fine except in outlook.
the out put of the script is meant to be a 2x2table with the 4 latest reviews in it. the only prob is outlook seems to hates me using Div for a table and stacks the 2x2 table into a verticle kaotic mess.
the code i'm trying to edit is:
'>
<?php /* root element for the items */ ?>
<div class="jrModuleItems <?php echo $orientation . ' jrThumbnail'.ucfirst($tn_position); ?>">
<?php /* new page starts here */
$pages = array_chunk($reviews,$limit);
$j=0;
foreach($pages AS $page):
?>
<div class="jr-results jrResults jrModuleContainer jrReviewsModule">
<?php $i=0;
while(!empty($page)):
$i++; $j++; $review = array_shift($page); ?>
<?php
// Process link title
$listing_title = ($listing_title_chars && mb_strlen($review['Listing']['title'])>$listing_title_chars) ? $Text->truncate($review['Listing']['title'],$listing_title_chars) : $review['Listing']['title'];
$review_title = ($review_title_chars && mb_strlen($review['Review']['title'])>$review_title_chars) ? $Text->truncate($review['Review']['title'],$review_title_chars) : $review['Review']['title'];
$link_title = str_replace('{listing_title}',$listing_title,$link_title_format);
$link_title = str_replace('{review_title}',$review_title,$link_title);
// Create the thumbnail
$tn_show and $mainMediaThumb = $Media->thumb(Sanitize::getVar($review,'MainMedia'),array('listing'=>$review,'size'=>$tn_size,'mode'=>$tn_mode,'css_size'=>true));
?>
<?php $lastItem = ($i == $columns) ? ' jrLastItem' : ''; ?>
<div class="jrModuleItem<?php echo $lastItem; ?>" style="width: <?php echo $item_width; ?>%; padding-right: <?php echo $item_padding; ?>%;">
<?php if($show_numbers):?><div class="jrModuleItemNumber"><?php echo $j;?>.</div><?php endif;?>
<?php if($tn_show && $mainMediaThumb && $tn_position != 'bottom'):?>
<!-- Listing Thumbnail -->
<div class="jrModuleItemThumbnail">
<?php echo $Html->sefLink($mainMediaThumb,$review['Listing']['url']);?>
<?php // Uncomment line below to show reviewer avatar. You can comment or remove the thumbnail code above
// echo $Community->avatar($review);
?>
</div>
<?php endif;?>
<div class="jrModuleItemContent">
<!-- Listing Title -->
<div class="jrModuleItemTitle">
<?php echo $Html->sefLink($link_title,$review['Listing']['url']);?>
<?php if(Sanitize::getString($review['Listing'],'tag')):?>
<span class="jrComponentLabel jrStatusLabel jrBlue">
<?php echo Sanitize::getString($review['Listing'],'tag');?>
</span>
<?php endif;?>
</div>
<!-- Rating -->
<?php if ( $review['Criteria']['state'] == 1 ):?>
<div class="jrOverallRatings">
<?php if($review['Review']['editor'] == 1):?>
<?php
$rating_stars = $Rating->drawStars($review['Rating']['average_rating'], $this->Config->rating_scale, 'editor');
$rating_value = $Rating->round($review['Rating']['average_rating'],$this->Config->rating_scale);
?>
<div class="jrOverallEditor" title="<?php __t("Editor rating"); ?>">
<div class="jrRatingStars"><?php echo $rating_stars ?></div>
<span class="jrRatingValue"><?php echo $rating_value?></span>
</div>
<?php else:?>
<?php
$rating_stars = $Rating->drawStars($review['Rating']['average_rating'], $this->Config->rating_scale, 'user');
$rating_value = $Rating->round($review['Rating']['average_rating'],$this->Config->rating_scale);
?>
<div class="jrOverallUser" title="<?php __t("User rating"); ?>">
<div class="jrRatingStars"><?php echo $rating_stars ?></div>
<span class="jrRatingValue"><?php echo $rating_value?></span>
</div>
<?php endif;?>
</div>
<?php endif;?>
<!-- Reviewer name -->
<div class="jrModuleItemReviewer">
<span class="reviewer"><?php __t("Reviewed by");?> <?php echo $Community->screenName($review);?></span>
</div>
<?php if($fields): ?>
<!-- Custom Fields -->
<div class="jrModuleFields">
<?php
foreach ($fields as $field):
$field = trim($field);
$field_value = $CustomFields->field($field,$review);
?>
<?php if($field_value != ''):?>
<div class="jrModuleFieldDiv <?php echo lcfirst(Inflector::camelize($field)); ?>">
<span class="jrModuleFieldTitle"><?php echo $CustomFields->label($field, $review); ?>: </span>
<span class="jrModuleFieldValue"><?php echo $field_value; ?></span>
</div>
<?php endif;?>
<?php endforeach; ?>
</div>
<?php endif;?>
<?php if($show_comments && trim($review['Review']['comments'])!=''):?>
<!-- Review Comments -->
<div class="jrModuleItemInfo">
<?php
// Uncomment line below to show review title
// echo '<strong>' . $review['Review']['title'] . '</strong><br />';
?>
<span class="comments">"<?php echo $Text->truncateWords($review['Review']['comments'],$comments_words,'...');?>"</span>
</div>
<?php endif;?>
</div>
<?php if($tn_show && $mainMediaThumb && $tn_position == 'bottom'):?>
<!-- Listing Thumbnail -->
<div class="jrModuleItemThumbnail">
<?php echo $Html->sefLink($mainMediaThumb,$review['Listing']['url']);?>
<?php // Uncomment line below to show reviewer avatar. You can comment or remove the thumbnail code above
// echo $Community->avatar($review);
?>
</div>
<?php endif;?>
</div>
<?php /*end of row , start new row*/
if(!empty($page) && ($i == $columns || $total == $j)):?>
<div class="jrDivider"></div>
<?php $i=0; endif;?>
<?php endwhile;?>
</div>
<?php endforeach; /* new page ends here */?>
</div><?php /* end items root element */?>
Does any one have the slightest idea how i could turn this into a for loop that outputs a table?
The quickest path from A to B is to edit the attached code to render a table versus stacked divs.
* EDIT *
The answer to your comment isn't so simple as replace all of 'A' with 'B.' A div is a "self-contained" HTML element while a table is a grouping with syntax rules.
An HTML table is constructed like so:
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1 - Column 1</td>
<td>Row 1 - Column 2</td>
</tr>
<tr>
<td>Row 2 - Column 1</td>
<td>Row 2 - Column 2</td>
</tr>
</tbody>
</table>
The foreach loop in your code should create a row through each iteration. Which means you need to render your table, thead and tbody tags outside of this looping code. Inside the loop, you render a new row each iteration, which requires an opening/closing tag for the row and an opening/closing for each column.
Hope this helps.
I'm trying to create something like part finder (product finder).
I was thinking to edit layered navigation.
So now I have drop-boxes instead of list using this code for
app/design/frontend/default/carpoint/template/catalog/layer/filter.phtml
<select onchange="setLocation(this.value)">
<?php $count = 0; ?>
<?php foreach ($this->getItems() as $_item): ?>
<?php $count++; ?>
<?php if($count == 1): ?>
<option value='' disabled selected style='display:none;'>Choose <?php echo $attribute_code = $_item->getFilter()->getName();?> </option>
<?php endif; ?>
<option <?php if ($_item->getCount() > 0): ?> value="<?php echo $this->urlEscape($_item->getUrl()) ?>">
<?php echo $_item->getLabel() ?> <?php else: echo '>' . $_item->getLabel() ?> <?php endif; ?> (<?php echo $_item->getCount() ?>) </option>
<?php endforeach; ?>
</select>
How can I edit custom attribute eg "Type" so he is associated with parent attribute eg "Brand".
I something like this:
I am using a script that runs on the YII framework...
I have this select box that lets a user view content based on their country. But right now, when a user selects their country, after the selection, it just shows the country name...
And what I want is, after a user selected their country... it must still show the select box, but have the selected country at the top of the list.
I have tried so many things but I'm still new to this this.
<?php if ( $_country == '' ) { ?>
<select onchange="changeCountry(this)" name="country" id="country">
<?php if ( count ($c) != 0 ) { ?>
<?php if ( $_country == NULL ) ?>
<?php foreach ($c as $id => $val) { ?>
<option<?php if ($id == $countryId) {?> selected="selected"<?php } ?> value="<?php echo mbCoreFunctions::to_seo_ad_name ($val, $id) ?>"><?php echo $val; ?></option>
<?php } ?>
<?php } ?>
</select>
<?php } else { ?>
<span class="countryName"><?php echo $countryName; ?></span>
<?php } ?>
I didn't try but following should work
<select onchange="changeCountry(this)" name="country" id="country">
<?php foreach ($c as $id => $val) { ?>
<option<?php if ($id == $countryId) {?> selected="selected"<?php } ?> value="<?php echo mbCoreFunctions::to_seo_ad_name ($val, $id) ?>"><?php echo $val; ?></option>
<?php } ?>
</select>
Using OpenCart as an ecommerce solution I'm trying to edit the cart page so that I can update option values in addition to quantity and have run into a bit of trouble.
My current code takes the correct option that's been chosen and puts it in a select box. Here's the code:
<?php foreach ($product['option'] as $option) { ?>
<div style="float: left; width: 100px;">
<select style=" text-align: left;" class="storeitems" name="option[<?php echo $option['option_id']; ?>]" selected="<?php echo $option['value']; ?>">
<option>
<?php echo $option['value']; ?>
</option>
</select>
</div>
<?php } ?>
Now, I need it to pull in the other options (as seen on the proudct page). Here is that code:
<select style="max-width: 145px;" class="storeitems" name="option[<?php echo $option['option_id']; ?>]" selected="<?php echo $option_value['name']; ?>">
<?php foreach ($option['option_value'] as $option_value) { ?>
<option value="<?php echo $option_value['option_value_id']; ?>"><?php echo $option_value['name']; ?>
</option>
<?php } ?>
</select>
In your second piece of code you have no product identification so opencart doesn't know what product to display options for.