I'm newbie and I would like to know the way to put search bar beside page selector.
Here's a screenshot now :
https://imgur.com/a/S9X3sIc
My desire layout :
https://imgur.com/a/0zx3rfl
How can I make it? I need your help. Thanks in advance. I love you guys. :D
<div class="wpf-navi <?php echo esc_attr($class) ?>">
<div class="wpf-navi-wrap">
<div id="wpf-widget-search" class="wpforo-widget-wrap"><form action="<?php echo wpforo_home_url() ?>" method="get">
<?php wpforo_make_hidden_fields_from_url( wpforo_home_url() ) ?>
<input type="text" placeholder="<?php wpforo_phrase('Search...') ?>" name="wpfs" class="wpfw-70" value="<?php echo isset($_GET['wpfs']) ? esc_attr(sanitize_text_field($_GET['wpfs'])) : '' ?>" ><input type="submit" class="wpfw-20" value="ยป">
</form></div>
<span class="wpf-page-info">
<?php wpforo_phrase('Page') ?> <?php echo intval($paged) ?> / <?php echo intval($pages_count) ?>
</span>
<?php if( $paged - 1 > 0 ): $prev_url = ( ($paged - 1) == 1 ? $sanitized_current_url : sprintf($url, $paged - 1) ); ?>
<a href="<?php echo esc_url( WPF()->user_trailingslashit($prev_url) ) ?>" class="wpf-prev-button" rel="prev">
<i class="fas fa-chevron-left fa-sx"></i> <?php wpforo_phrase('prev') ?>
</a>
<?php endif ?>
<select class="wpf-navi-dropdown" onchange="if (this.value) window.location.assign(this.value)" title="<?php esc_attr( wpforo_phrase('Select Page') ) ?>">
<option value="<?php echo esc_url( WPF()->user_trailingslashit($sanitized_current_url) ) ?>" <?php wpfo_check($paged, 1, 'selected') ?>>1</option>
<?php for($i = 2; $i <= $pages_count; $i++) : ?>
<option value="<?php echo esc_url( WPF()->user_trailingslashit( sprintf($url, $i) ) ) ?>" <?php wpfo_check($paged, $i, 'selected') ?>>
<?php echo $i ?>
</option>
<?php endfor; ?>
</select>
<?php if( $paged + 1 <= $pages_count ): ?>
<a href="<?php echo esc_url( WPF()->user_trailingslashit(sprintf($url, $paged + 1) ) ) ?>" class="wpf-next-button" rel="next">
<?php wpforo_phrase('next') ?> <i class="fas fa-chevron-right fa-sx"></i>
</a>
<?php endif ?>
</div>
</div>
Related
<input class="filtered a_name" id="attribute_value_1560" type="checkbox" name="attribute_value[156][]" at_v_i="156_A+++/A++" value="A+++/A++">
<table>
<?php foreach($attribute_value['values'] as $i => $value) { ?>
<tr>
<td>
<input class="filtered a_name"
id="attribute_value_<?php echo $attribute_value_id . $i; ?>"
type="checkbox" name="attribute_value[<?php echo $attribute_value_id?>][]"
at_v_i="<?php echo $attribute_value_id . '_' . $value; ?>"
value="<?php echo $value ?>">
</td>
<td>
<label for="attribute_value_<?php echo $attribute_value_id . $i; ?>"
at_v_t="<?php echo $attribute_value_id . '_' . htmlspecialchars(preg_replace('/\s+|\n|\r|\s+$/m', '_', $value)); ?>"
data-value="<?php echo $value; ?>"
value="<?php echo $value ?>"><?php echo $value?></label>
</td>
</tr>
<?php } ?>
</table>
I'm getting this error:
Attribute at_v_i not allowed on element input at this point.
How can I solve this?
I am creating my first online shop.
Problem: I want to show, error message for quantity validation.
Stock quantity is not showing in product detail page but it is showing in cart page. I have share both pages screenshot below.
Product Detail: http://prntscr.com/93ajnj
Cart: http://prntscr.com/93ajuk
I have use below code in woocommerce > single-product > add-to-cart > variable.php
<div class="quantity"><strong>Quantity </strong>
<input type="number" step="<?php echo esc_attr( $step ); ?>" <?php if ( is_numeric( $min_value ) ) : ?>min="<?php echo esc_attr( $min_value ); ?>"<?php endif; ?> <?php if ( is_numeric( $max_value ) ) : ?>max="<?php echo esc_attr( $max_value ); ?>"<?php endif; ?> name="<?php echo esc_attr( $input_name ); ?>" value="<?php echo esc_attr( $input_value ); ?>" class="input-text qty text" size="4" oninvalid="setCustomValidity('Sorry! we have only <?php echo esc_attr( $max_value ); ?> shirts in your selected size.')"
onchange="try{setCustomValidity('')}catch(e){}" />
</div>
Any help in this regards will be highly appreciated. Thanks in advance.
P.S. link of website.
So like I said in the title, I am creating a recent posts widget for practice. It includes different features and the one that I am having problems with it is allowing admin to choose the category they want to display. I currently have it set up so that in the form it has a text field in which the admin can input the category manually but I need it to be such that it has a drop down menu that already has the category there, so the admin can just select it. I am not sure how to do this at all so if I could get some help that would be great. Sorry if I am being vague, I am new to this. I am posting my code below.
<?php
/*
Plugin Name: News Recent Posts Widget
Plugin URI:
Description: A recent post widget with extra functions that allow admin to make changes to certain values
Author: Kevin Ullyott
Version: 1.0
Author URI: http://modmacro.com/
*/
class recentpost extends WP_Widget {
public function __construct() {
parent::WP_Widget(
// or parent::__construct(
false,
'Kevin - Recent Posts Widget',
array(
'description' => __('A recent post widget with extra functions that allow admin to make changes to certain values')
)
);
;
}
public function widget( $args, $instance ) {
extract( $args );
$headline = $instance['headline'];
$category = $instance['category'];
$numberposts = $instance['numberposts'];
$readmore = $instance['readmore'];
echo $before_widget;
echo $before_title;
echo "<p class=\"headline\">$headline</p>";
echo $after_title;
$args = array( 'numberposts' => $numberposts, 'category_name' => $category );
$recent_posts = wp_get_recent_posts( $args );
foreach( $recent_posts as $recent ){
setup_postdata(get_post($recent['ID']));
echo '<a href="' . get_permalink($recent['ID']) . '" title=" '.esc_attr(get_the_title($recent['ID'])).'" >' . get_the_title($recent['ID']).'</a> ';
echo get_the_time('F j, Y', $recent['ID']);
the_excerpt();
}
wp_reset_postdata();
echo $after_widget;
}
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['headline'] = ( $new_instance['headline'] );
$instance['category'] = ( $new_instance['category'] );
$instance['numberposts'] = ( $new_instance['numberposts'] );
$instance['readmore'] = ( $new_instance['readmore'] );
return $instance;
}
public function form( $instance ) {
$headline = $instance[ 'headline' ];
$category = $instance[ 'category' ];
$numberposts = $instance[ 'numberposts' ];
$readmore = $instance[ 'readmore' ];
?>
<p>
<label for="<?php echo $this->get_field_id( 'headline' ); ?>">
<?php _e( 'Headline:' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id( 'headline' ); ?>" name="<?php echo $this->get_field_name( 'headline' ); ?>" type="text" value="<?php echo esc_attr( $headline ); ?>" />
</p>
<label for="<?php echo $this->get_field_id( 'category' ); ?>">
<?php _e( 'Category:' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id( 'category' ); ?>" name="<?php echo $this->get_field_name( 'category' ); ?>" type="text" value="<?php echo esc_attr( $category ); ?>" />
</p>
<label for="<?php echo $this->get_field_id( 'numberposts' ); ?>">
<?php _e( 'Number of posts:' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id( 'numberposts' ); ?>" name="<?php echo $this->get_field_name( 'numberposts' ); ?>" type="text" value="<?php echo esc_attr( $numberposts ); ?>" />
</p>
<label for="<?php echo $this->get_field_id( 'readmore' ); ?>">
<?php _e( 'Read More:' ); ?>
</label>
<input class="widefat" id="<?php echo $this->get_field_id( 'readmore' ); ?>" name="<?php echo $this->get_field_name( 'readmore' ); ?>" type="text" value="<?php echo esc_attr( $readmore ); ?>" />
</p>
<?php
}
}
add_action( 'widgets_init', create_function('', 'return register_widget("recentpost");') );
?>
The function wp_dropdown_categories will bring in the categories but adding the function alone wont save or retrieve the selected category. You'll need to add the name selected and id arguments. This should work I think:
<?php wp_dropdown_categories(array('name' => $this->get_field_name('category'), 'selected' => $category, 'id' => $this->get_field_id('category'), 'class' => 'widefat')); ?>
I added class widefat as well but its only for presentation. Hope that helps.
The function wp_dropdown_categories displays a dropdown menu that pulls in all of the categories used in the site. Here is the documentation on it: http://codex.wordpress.org/Function_Reference/wp_dropdown_categories
So you can replace
get_field_id( 'category' ); ?>" name="get_field_name( 'category' ); ?>" type="text" value="" />
with a call to the wp_dropdown_categories function.
In my project I have to display the webshop in two languages.
By default you can choose languages with the following code in:
app/design/frontend/base/default/template/page/switch/language.phtml
<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<label for="select-language"><?php echo $this->__('Your Language:') ?></label>
<select id="select-language" title="<?php echo $this->__('Your Language') ?>" onchange="window.location.href=this.value">
<?php foreach ($this->getStores() as $_lang): ?>
<?php $_selected = ($_lang->getId() == $this->getCurrentStoreId()) ? ' selected="selected"' : '' ?>
<option value="<?php echo $_lang->getCurrentUrl() ?>"<?php echo $_selected ?>><?php echo $this->htmlEscape($_lang->getName()) ?></option>
<?php endforeach; ?>
</select>
</div>
<?php endif; ?>
This of course displaya a select box with the options being all the languages.
I however want to change this so that it become seperate links.
I just don't really know how to do this.
This is what I have now.
<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<?php foreach ($this->getStores() as $_lang):?>
<?php echo $this->htmlEscape($_lang->getName()) ?>
<?php endforeach;?>
</div>
<?php endif; ?>
PS: I did not change this in the default magento code. I am working in app/design/frontend/default/projectname/template/page/switch/language.phtml.
So I managed to get this working by myself with this code:
<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<?php foreach ($this->getStores() as $_lang):?>
<?php echo $this->htmlEscape($_lang->getName()) ?>
<?php endforeach;?>
</div>
<?php endif; ?>
But now when I switch language. It redirects to the home page.
I found I should use:
$_lang->getCurrentUrl()
But I have no idea where to place this in my code.
You're very close, you just need to include the URL!
<?php if(count($this->getStores())>1): ?>
<div class="form-language">
<?php foreach ($this->getStores() as $_lang):?>
<?php echo $this->htmlEscape($_lang->getName()) ?>
<?php endforeach;?>
</div>
<?php endif; ?>
This seems to be different in Enterprise compared to Community. This is what the code is like in Magento Enterprise v1.12. Maybe it is of use, or maybe it works as well.
<?php if(count($this->getStores())>1): ?>
<div class="switch switcher-language">
<label><?php echo $this->__('Language') ?>:</label>
<div class="switch-wrapper" id="languageSelect">
<strong class="current language-<?php echo $this->htmlEscape(Mage::app()->getStore()->getCode()) ?>">
<?php echo $this->htmlEscape(Mage::app()->getStore()->getName()) ?>
</strong>
<span class="switcher-holder">(<span onclick="popUpMenu(this);" class="switcher"><?php echo $this->__('Change')?></span>)</span>
<ul style="display:none" id="popId-languageSelect">
<li class="current language-<?php echo $this->htmlEscape(Mage::app()->getStore()->getCode()) ?>">
<span><?php echo $this->htmlEscape(Mage::app()->getStore()->getName()) ?></span>
</li>
<?php foreach ($this->getStores() as $_lang): ?>
<?php if($_lang->getId()!=$this->getCurrentStoreId()): ?>
<li class="language-<?php echo $this->htmlEscape($_lang->getCode()); ?>">
<?php echo $this->htmlEscape($_lang->getName()) ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
</div>
<?php endif; ?>
Try this code. I tested in EE 1.12.
<?php if(count($this->getStores())>1): ?>
<ul>
<?php foreach ($this->getStores() as $_lang): ?>
<?php if($_lang->getId()!=$this->getCurrentStoreId()): ?>
<li class="language-<?php echo $this->htmlEscape($_lang->getCode()); ?>">
<?php echo $this->htmlEscape($_lang->getName()) ?>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
<?php endif; ?>
HELLO,
i have an html select list, and i want: the selected number to be a given value $content->number, and the maximum value to be $content->product_type->stock_2 if it is less than 5, or 5 if it is greater than 5.
now i have:
<select class="number" name="number">
<? $max = $content->product_type->stock_2 > 5 ? 5 : $content->product_type->sale_stock; ?>
<option value="<?= $content->number ?>"><?= $content->number; ?> </option>
<? for ($i = 1; $i <= $max; $i++):?>
<option <?php if($content->product_type->stock_2 == $i) echo 'selected="selected"' ;?> value="<?= $i ?>"><?= $i; ?></option>
<? endfor; ?>
</select>
but it shows me twice the selected value $content->number. i'm sure i am mistaking somewhere.
Any suggestions?
thank you!
I do not know whether I correct understood what you want to do, but try this:
<select class="number" name="number">
<? $max = $content->product_type->stock_2 > 5 ? 5 : $content->product_type->sale_stock; ?>
<option value="<?= $content->number ?>"><?= $content->number; ?> </option>
<? for ($i = 1; $i <= $max; $i++):?>
<? if ($i != $content->number): ?>
<option <?php if($content->product_type->stock_2 == $i) echo 'selected="selected"' ;?> value="<?= $i ?>"><?= $i; ?></option>
<? endif; ?>
<? endfor; ?>
</select>