Jump to content

Office Space rental website


Recommended Posts

Hello All,

I am developing an 'Office Space Rental' website using Prestashop.

My requirement is -

# I need to show all the 'amenities' of a property (e.g coffee m/c, WiFi, Security, Projector etc) on the 'Products Listing' page and 'Product Details' page. One property would have one or more amenities.

# These amenities would also be filtering options on the Products Listing page, as facets.

 

Please help how to configure these OOB as I don't find it possible with Product Attribute and Product Features. if not possible, what would be my design and implementation approach.

 

Regards, Katyayan

Link to comment
Share on other sites

You could use product features such as "Coffee Machine" with "Yes" and "No" values and then use the layered navigation to filter by feature. The only problem is that you'll see "Coffee Machine: No" on the product page and in the filter. You could fix this with some simple modifications though.

 

For example, to hide features with the value "No", you could change lines 475 (in PrestaShop v1.6.1.7) of themes/default-bootstrap/product.tpl from:

						{if isset($feature.value)}

to:

						{if isset($feature.value) && $feature.value != 'No'}

You'll have to translate the feature value as 'No' in all languages for the above code to work, but that's fine since you won't be displaying the value.

 

You'll also need to modify themes/default-bootstrap/modules/blocklayered/blocklayered.tpl to hide the "No" values from there. You can change lines 70-86 (in PrestaShop v1.6.1.7) from:

				{foreach from=$filters item=filter}
					{if isset($filter.values)}
						{if isset($filter.slider)}
							<div class="layered_{$filter.type}" style="display: none;">
						{else}
							<div class="layered_filter">
						{/if}
                        <div class="layered_subtitle_heading">
                            <span class="layered_subtitle">{$filter.name|escape:'html':'UTF-8'}</span>
                            <!--<span class="layered_close">
                            	<a href="#" data-rel="ul_layered_{$filter.type}_{$filter.id_key}"></a>
                            </span>-->
						</div>
						<ul id="ul_layered_{$filter.type}_{$filter.id_key}" class="col-lg-12 layered_filter_ul{if isset($filter.is_color_group) && $filter.is_color_group} color-group{/if}">
							{if !isset($filter.slider)}
								{if $filter.filter_type == 0}
									{foreach from=$filter.values key=id_value item=value name=fe}

to:

				{foreach from=$filters item=filter}
					{if isset($filter.values)}
                        {assign var='hasNo' value=false}
                        {foreach from=$filter.values item=value}
                            {if $value.name == 'No'}
                                {assign var='hasNo' value=true}
                                {break}
                            {/if}
                        {/foreach}
						{if isset($filter.slider)}
							<div class="layered_{$filter.type}" style="display: none;">
						{else}
							<div class="layered_filter">
						{/if}
                        {if !$hasNo}
                        <div class="layered_subtitle_heading">
                            <span class="layered_subtitle">{$filter.name|escape:'html':'UTF-8'}</span>
                            <!--<span class="layered_close">
                            	<a href="#" data-rel="ul_layered_{$filter.type}_{$filter.id_key}"></a>
                            </span>-->
						</div>
                        {/if}
						<ul id="ul_layered_{$filter.type}_{$filter.id_key}" class="col-lg-12 layered_filter_ul{if isset($filter.is_color_group) && $filter.is_color_group} color-group{/if}">
							{if !isset($filter.slider)}
								{if $filter.filter_type == 0}
									{foreach from=$filter.values key=id_value item=value name=fe}
										{if $hasNo}{if $value.name == 'No'}{assign var=$value.name value=$filter.name}{else}{continue}{/if}{/if}

This will create a {$hasNo} variable that is set to true if a feature contains the value 'No'. This variable is then used to remove the filter heading and put the filter name as the feature value.

Link to comment
Share on other sites

Hi Rockey,
Thank a lot for the solution, it worked very well. Big help.
With a little change from your suggestion, I can display 'amenities' both on PDP and in Layered Navigation as filters.
 
I used product features such as "Coffee Machine" with only 'Yes', If I don't set the feature for a product, anyways it is not displayed. 
Changes - 

 

# themes/default-bootstrap/product.tpl at line #477
{if $feature.value != 'Yes'}
<td>{$feature.value|escape:'html':'UTF-8'}</td>
{/if}

----------------------------------------------------------------------------

#themes/default-bootstrap/modules/blocklayered/blocklayered.tpl
{foreach from=$filters item=filter}

{if isset($filter.values)}
<!-- my change start -->
{assign var='hasYes' value=false}
{foreach from=$filter.values item=value}
{if $value.name == 'Yes'}
{assign var='hasYes' value=true}
{break}
{/if}
{/foreach}
<!-- my change end -->
{if isset($filter.slider)}
<div class="layered_{$filter.type}" style="display: none;">
{else}
<div class="layered_filter">
{/if}
<!-- my change start -->
{if !$hasYes}
<div class="layered_subtitle_heading">
<span class="layered_subtitle">{$filter.name|escape:'html':'UTF-8'}</span>
<!--<span class="layered_close">
<a href="#" data-rel="ul_layered_{$filter.type}_{$filter.id_key}"></a>
</span>-->
</div>
{/if}
<!-- my change end -->
<ul id="ul_layered_{$filter.type}_{$filter.id_key}" class="col-lg-12 layered_filter_ul{if isset($filter.is_color_group) && $filter.is_color_group} color-group{/if}">
{if !isset($filter.slider)}
{if $filter.filter_type == 0}
{foreach from=$filter.values key=id_value item=value name=fe}
<!-- my change start -->
{if $hasYes}
{if $value.name == 'Yes'}
{assign var=$value.name value=$filter.name}
<!-- {else}
{continue}{$value.name|escape:'html':'UTF-8'}
{/if}-->
{/if} 
<!-- my change end -->
{if $value.nbr || !$hide_0_values}
<li class="nomargin {if $smarty.foreach.fe.index >= $filter.filter_show_limit}hiddable{/if} col-lg-12">
{if isset($filter.is_color_group) && $filter.is_color_group}
<input class="color-option {if isset($value.checked) && $value.checked}on{/if} {if !$value.nbr}disable{/if}" type="button" name="layered_{$filter.type_lite}_{$id_value}" data-rel="{$id_value}_{$filter.id_key}" id="layered_id_attribute_group_{$id_value}" {if !$value.nbr}disabled="disabled"{/if} style="background: {if isset($value.color)}{if file_exists($smarty.const._PS_ROOT_DIR_|cat:"/img/co/$id_value.jpg")}url(img/co/{$id_value}.jpg){else}{$value.color}{/if}{else}#CCC{/if};" />
{if isset($value.checked) && $value.checked}<input type="hidden" name="layered_{$filter.type_lite}_{$id_value}" value="{$id_value}" />{/if}
{else}
<input type="checkbox" class="checkbox" name="layered_{$filter.type_lite}_{$id_value}" id="layered_{$filter.type_lite}{if $id_value || $filter.type == 'quantity'}_{$id_value}{/if}" value="{$id_value}{if $filter.id_key}_{$filter.id_key}{/if}"{if isset($value.checked)} checked="checked"{/if}{if !$value.nbr} disabled="disabled"{/if} /> 
{/if}
<label for="layered_{$filter.type_lite}_{$id_value}"{if !$value.nbr} class="disabled"{else}{if isset($filter.is_color_group) && $filter.is_color_group} name="layered_{$filter.type_lite}_{$id_value}" class="layered_color" data-rel="{$id_value}_{$filter.id_key}"{/if}{/if}>
{if !$value.nbr}my change3
{$value.name|escape:'html':'UTF-8'}{if $layered_show_qties}<span> ({$value.nbr})</span>{/if}
{else}
<a href="{$value.link}"{if $value.rel|trim != ''} data-rel="{$value.rel}"{/if}>
<!-- my change start -->
{if $hasYes}{$filter.name|escape:'html':'UTF-8'}{else}{$value.name|escape:'html':'UTF-8'}{/if}
<!-- my change end -->
Link to comment
Share on other sites

  • 2 weeks later...

I am getting error "Illegal string offset 'name' " in my code below at this line {if $value.name == 'Yes'} - 

{foreach from=$filters item=filter}
					{if isset($filter.values)}
						<!-- my change start -->
							{assign var='hasYes' value=false}
							{foreach from=$filter.values item=value}
								{if $value.name == 'Yes'}
									{assign var='hasYes' value=true}
									{break}
								{/if}
							{/foreach}
                                                                                                    <!-- my change end -->

Please suggest.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...