Osclass search from homepage to search for location also - search

I am trying to configure osclass for a real estate website. when searching from the home page, i need the search keywords to be searched in city and region too... ie, if the search key is "apartment newyork", all apartments where city or region is newyork should be displayed.

for the city filter try this one
<?php $aCities = City::newInstance()->listAll(); ?>
<?php if(count($aCities) > 0 ) { ?>
<select name="sCity" id="sCity">
<option value=""><?php _e('Select a city...')?></option>
<?php foreach($aCities as $city) { ?>
<option value="<?php echo $city['s_name'] ; ?>">
<?php echo $city['s_name'] ; ?></option>
<?php } ?>

Related

Show optgroup in selected values in selctize.js

We have a selectize field where multiple values can be selected. These values are grouped in optgroups. To ease understanding, some values can be in multiple optgroups, we would like to see the name of the optgroup in the labels for the selected fields, too. How can we accomplish this?
See following fiddle, if you select "First Item" you do not know which one was selected, Store or Warehouse.
Thanks!
https://jsfiddle.net/4t8fjj7g/1/
HTML:
<select name="test" id="test-select" multiple="multiple">
<optgroup label="Store">
<option data-type="stores" value="1">First item</option>
<option data-type="stores" value="2">Second item</option>
</optgroup>
<optgroup label="Warehouse">
<option data-type="warehouses" value="3">First item</option>
<option data-type="warehouses" value="4">Second item</option>
</optgroup>
</select>
And this is the javascript code:
$('select#test-select').selectize({
searchField: ['text', 'type']
});
Basically, what Daffy has suggested, BUT...
You can use custom rendering functions for dropdown options and for selected items:
$('select#test-select').selectize({
searchField: ['text', 'type'],
render: {
item: itemRenderFunction,
option: optionRenderFunction
}
});
This will allow you to avoid label multiplication in selected items list.
What I did is have the values have the optgroup then the value like optgroup_value then when the form gets submitted on the server or doing something in JS I can get it by exploding the string like:
<select multiple class="my-select">
<optgroup label="taxes">
<?php foreach ( $taxes as $tax) : ?>
<option value="tax_<?php echo $tax->slug; ?>"><?php echo $tax->name; ?></option>
<?php endforeach; ?>
</optgroup>
<optgroup label="Version">
<?php foreach ( $my_versions as $version ) : ?>
<option value="version_<?php echo $version->slug; ?>"><?php echo $version->name; ?></option>
<?php endforeach; ?>
</optgroup>
<optgroup label="Language">
<?php foreach ( $my_languages as $language ) : ?>
<option value="language_<?php echo $language->slug; ?>"><?php echo $language->name; ?></option>
<?php endforeach; ?>
</optgroup>
</select>
then
<?php
foreach ( $_POST['taxes'] as $val ) {
if ( ! empty( $val ) ) {
// $val_parts is an array with
// $val_parts[0] = optgroup only
// $val_parts[1] = the value of the option minus optgroup
$val_parts = explode( "_", $val );
// My use case to add a meta_query to a WP_Query so add filter based on both values
$meta_arg = array(
'taxonomy' => "my_" . $val_parts[0], // custom prefix then optgroup
'field' => 'slug',
'terms' => $val_parts[1] // value
);
// Add to running array and possibly do again
array_push( $args['tax_query'], $meta_arg );
}
}

Displaying All Data from Custom Post Type Fields through Advanced Custom Fields

I have looked all over Google, trying to figure this out. I've made some progress but still stuck. I'm pretty new to ACF and custom post types. I have a custom post type of Attorneys that I setup through WCK. That post type has a field group with field names of attorney_photo, attorney_name and attorney_areas_of_practice. With the code below, I can get the attorney_name and attorney_areas_of_practice (repeater field) to display, but not the attorney_photo. I have the info displaying correctly on each attorneys specific page, but I need this page to be a listing of all the attorneys. Not sure what I am doing wrong with the image part.
<?php get_header(); ?>
<?php
$args = array(
'posts_per_page' => 30,
'order' => 'ASC',
'orderby' => 'title',
'post_type' => 'attorneys'
);
query_posts($args);
if ( have_posts() ) :
?>
<?php while ( have_posts() ) : the_post(); ?>
<div class="attorney-preview">
<?php $photo = get_post_meta($post->ID,'attorney_photo', true); ?>
<img src="<?php echo $photo; ?>" />
<p><strong><?php echo get_post_meta($post->ID,'attorney_name', true); ?></strong></p>
<ul>
<?php
while ( have_rows('attorney_areas_of_practice') ) : the_row();
$attorney_area_of_practice = get_sub_field('attorney_area_of_practice');
echo "<li>" . $attorney_area_of_practice . "</li>";
endwhile;
?>
</ul>
</div><!-- .attorney-preview -->
<?php endwhile; ?>
<?php endif; ?>
<?php
wp_reset_query(); // Restore global post data stomped by the_post().
?>
<?php get_footer(); ?>
When you add image field through ACF plugin there are some options of return value. For example return value is: image object or return value is: image url, in your case return value might be selected as image object, not image url. That is why here with your code is being returned an array rather than only url. To get only image url from this array, please write as following a bit change:
<?php $photo = get_post_meta($post->ID,'attorney_photo', true); ?>
<img src="<?php echo $photo['url']; ?>" />
Try this
<?php query_posts(array('posts_per_page' => 30,'order' => 'ASC','orderby' => 'title','post_type' => 'attorneys'));
if (have_posts()) : while (have_posts()) : the_post();
$attorney_photo = get_post_meta($post->ID, 'attorney_photo', true);
$attorney_name = get_post_meta($post->ID, 'attorney_name', true); ?>
<div class="attorney-preview">
<img src="<?php echo $attorney_photo; ?>" />
<p><strong><?php echo $attorney_name; ?></strong></p>
<ul>
<?php
while ( have_rows('attorney_areas_of_practice') ) : the_row();
$attorney_area_of_practice = get_sub_field('attorney_area_of_practice');
echo "<li>" . $attorney_area_of_practice . "</li>";
endwhile;
?>
</ul>
</div><!-- .attorney-preview -->
<?php endwhile; endif; ?>
<?php
wp_reset_query(); // Restore global post data stomped by the_post().
?>

Hiding some configurable attribute in the front-end - magento

Please help...anyone
I have a problem with hiding some configurable attributes:
These are my configurable attributes at the back-end:
Shape/Type
Grit & Colour
Shank
Items pack
Diameter
Supplier
My client wants to hide the "Manufacturer" attribute on the front-end
but wants to import the supplier at the back-end.
Please see the website I am working:
http://ridental.com.au/newsite/polishers.html/
I managed to hide it from front-end by just adding some if statement
like this: in the app\design\frontend\default\MYTEMPLATE\template\catalog\product\view\type\options\configurable.phtml
<?php
$_product = $this->getProduct();
$_attributes = Mage::helper('core')->decorateArray($this->getAllowAttributes());
?>
<?php if ($_product->isSaleable() && count($_attributes)):?>
<dl class="outer">
<dl class="inner">
<?php foreach($_attributes as $_attribute): ?>
<?php $attCode = $_attribute->getProductAttribute()->getFrontend()->getAttribute()->getAttributeCode(); ?>
<?php if($attCode != "manufacturer"):?>
<div class="dtdd-wrapper<?php if ($_attribute->decoratedIsLast){echo " last";}?>">
<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>
</dl>
<script type="text/javascript">
[b]var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);[/b]
</script>
The Manufacturer will not be displayed on the front-end.
But when I click Add to Cart button I got the error:
Please specify the product's option(s).
I noticed that in:
var spConfig = new Product.Config(<?php echo $this->getJsonConfig()
It is still referring to the attribute "supplier" and waiting for the user response to choose Manufacturer in the drop down.
that's why I get the error: Please specify the product's option(s).
My question:
Is it possible to filter the function getJsonConfig()?
let say not include the:
if ($attributecode != 'manufacturer'){
do some stuff.....
}
I copied a local version of this function and now found in: app\code\local\Mage\Catalog\Block\Product\View\Type\Configurable.php
Please help...if anyone accomplished this kind of problem.
I tried extending getJsonConfig() to filter some attribute like "supplier" but to no avail.
Am I doing the right thing?
Chances are, from what you are describing, you should remake the configurable product without using the "Supplier" attribute.
When you make a configurable product, the first screen that allows you to mark attributes with check boxes is meant to define what the configurable product will be filtering, the attributes will still be attached to the product information.

PHPExcel reading xls file, get cell styling (font-weight, color, etc)

I am trying to read an excel file and render it as a html table. I would like to get the style that has been applied in excel to a cell and render it in html as well. For example, some cells may have text in BOLD, how do I get that information and use it in the most efficient way?
This is the code I have so far (I am trying out PHPExcel the first time so I am eager to hear any comments or improvements I can make to this):
if ($_GET["xls"]) {
require_once("classes/PHPExcel.php");
$objPHPExcel = PHPExcel_IOFactory::load( dirname(__FILE__) . "/demo.xls" );
$sheetData = $objPHPExcel->getSheetByName('Sheet1')->toArray(null,true,true,true);
?>
<?php if ( count($sheetData) < 0) : ?>
<table class="table striped">
<?php foreach( $sheetData as $y => $row ) : ?>
<tr>
<?php foreach ( $row as $x => $cell) : ?>
<?php if ( $x === "A" ) : ?>
<th><?php echo $cell; ?></th>
<?php else : ?>
<td><?php echo $cell; ?></td>
<?php endif; ?>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
<?php
}
Why not take a look at PHPExcel's existing HTML Writer: that already handles merged cells, cell formatting (including borders), font styles, etc.
It seems that the following code works:
$objPHPExcel->getSheetByName('Sheet1')->getStyle("B13")->getFont()->getBold()

How to theme exposed filter items in views - drupal 6

I'm attempting to put a bit of style on a specific set of exposed filters on a view that I have created.
The view is called user_search and so I have created views-exposed-form--user-search.tpl.php and that didn't work (all it did was remove the exposed filters but still displayed the view). views-exposed-form--user-search--page.tpl.php also got the same results.
Even if it did work, I still don't know what to put there to get the form to show up, just so that I can add styles or container divs.
print drupal_render($form); did not work.
I found a solution after a lot of digging.
First, you have to find the views-exposed-form.tpl.php file which should be located in sites/all/modules/views/theme/ folder. We're using the acquia stack so it was located in the vendor/ folder.
Copy this to themes/YOUR-THEME/ folder and rename it to views-exposed-form--your-view-name.tpl.php
If you only want to effect a specific display of your view name it to views-exposed-form--your-view-name--display.tpl.php
You can then use the existing framework to edit it as you see fit. Here's an example.
<?php
// $Id: views-exposed-form.tpl.php,v 1.4.4.1 2009/11/18 20:37:58 merlinofchaos Exp $
/**
* #file views-exposed-form.tpl.php
*
* This template handles the layout of the views exposed filter form.
*
* Variables available:
* - $widgets: An array of exposed form widgets. Each widget contains:
* - $widget->label: The visible label to print. May be optional.
* - $widget->operator: The operator for the widget. May be optional.
* - $widget->widget: The widget itself.
* - $button: The submit button for the form.
*
* #ingroup views_templates
*/
?>
<?php if (!empty($q)): ?>
<?php
// This ensures that, if clean URLs are off, the 'q' is added first so that
// it shows up first in the URL.
print $q;
?>
<?php endif; ?>
<div class="views-exposed-form">
<div class="views-exposed-widgets clear-block">
<?php foreach($widgets as $id => $widget): ?>
<div class="views-exposed-widget">
<?php if (!empty($widget->label)): ?>
<label for="<?php print $widget->id; ?>">
<?php print $widget->label; ?>
</label>
<?php endif; ?>
<?php if (!empty($widget->operator)): ?>
<div class="views-operator">
<?php print $widget->operator; ?>
</div>
<?php endif; ?>
<div class="views-widget">
<?php print $widget->widget; ?>
</div>
</div>
<?php endforeach; ?>
<div class="views-exposed-widget">
<?php print $button ?>
</div>
</div>
</div>
When in doubt about how to theme a part of a page, install the Theme Developer module. It will allow you to see what theme file or function is currently outputting a specific area of the page, as well as what files or functions can be used to override it. See the screencast for more detailed information.

Resources