Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chunk not rendering results after upgrade to 2.0.0-beta2 #91

Open
crimsonpixel opened this issue May 7, 2020 · 7 comments
Open

Chunk not rendering results after upgrade to 2.0.0-beta2 #91

crimsonpixel opened this issue May 7, 2020 · 7 comments

Comments

@crimsonpixel
Copy link

crimsonpixel commented May 7, 2020

Recently upgraded this extra and now I am not getting any results in my output.

Site is running on MODX 2.7.3, PHP 7.3 and Zend libraries included

I am using the following call on my results page:

[[!AdvSearch? &queryHook=`propertyQHook` &showExtract=`1:price` &containerTpl=`propertyAdvSearchResults` &tpl=`SearchResultTpl` &perPage=`5` ]]

And whilst the page returns results, none of the placeholders in the chunk are returned. I have prefixed all the placeholders with advsearch. but still nothing comes back.

Below is an extract from my chunk:

``


Property Type: [[+advsearch.property_type:ucwords]]


[[+advsearch.bedrooms:is=1:then=`1 bedroom`:else=`[[+advsearch.bedrooms]] bedrooms`]]


[[+advsearch.heating]]

[[+advsearch.furnish]]

Availability: [[+advsearch.availability:strtotime:date=`%e %b %Y`]]

``

There is nothing in the error log to suggest the issue.

My snippet is:

``<?php
/**

*/

/*
Main class:

package - The name of the schema Package to add. e.g: dvd
packagePath - The path to the model/ directory where the package is located. Use {core_path} as generic variable.
class - The class name of the table you want to search. e.g: dvd

and optionally (these parameters could be passed thru the snippet call):

withFields - A comma-separated list of column names where to search.
fields - A comma-separated list of column names to display. 
ids - A comma-separated list of primary keys to filter where the search should occurs.
where - criteria or Array of criteria. e.g: "studio IN ('20th Century Fox','DreamWorks Home Ent.','Warner Bros') "
sortby - csv list of couple 'columnName (ASC| DESC)'.

*/

$main = array(
'package' => 'lettings',
'packagePath' => '{core_path}components/lettings/model/',
'class' => 'Lettings',
'fields' => 'feature_image , street , town , county , price , bedrooms , property_type , heating , furnish , availability , status', // displayed
'withFields' => 'property_name , town , bedrooms , property_type , generic_property_type , bedrooms , price', // where we do the search
'where' => '(Lettings.published = 1)',
'sortby' => 'Lettings.price DESC',
'tablePrefix' => 'tls_'
);

$andConditions = array(
'Lettings.town:=' => 'town:request:all',
'Lettings.generic_property_type:=' => 'generic_property_type:request:all',
'Lettings.price:>=' => 'min-price:request:none',
'Lettings.price:<=' => 'max-price:request:none',
'Lettings.bedrooms:=' => 'bedrooms:request:all'
);

//$main['tablePrefix'] = 'modx_';

// set the query hook declaration
$qhDeclaration = array(
'qhVersion' => '1.2', // version of queryHook - to manage futures changes
'main' => $main,
'andConditions' => $andConditions
);

$hook->setQueryHook($qhDeclaration);
return true;``

Please could you suggest a resolution.

@BenceSzalai
Copy link

Can you please wrap your code blocks in double or triple backtick, so they are readable?

So to display this: [[!AdvSearch? &queryHook=`propertyQHook`... type this: ``` [[!AdvSearch? &queryHook=`propertyQHook`... ```.

It'd be easier to help if decoding of your code was not an issue. ;)

@crimsonpixel
Copy link
Author

crimsonpixel commented May 7, 2020

OK - I've updated it. Does that work? Or I can add a file instead

@BenceSzalai
Copy link

Could benefit the other two code sections too, since those are hard to read as well right now.

@crimsonpixel
Copy link
Author

@BenceSzalai
Copy link

Well, I was just trying to help so you can submit readable ModX code segments in markdown, which in turn would help you to get meaningful answers.

Regarding your issue: I've had lot of problems with v2.0.0-beta2 around not handling extracts properly. I have lot of fixes in my local repo, but haven't got the time yet to make PRs for them. I'll take a look at some point and I may be able to help or at least to explain why is it not working.

Will keep an eye out for this ticket.

For reference:
Your snippet:

<?php
/**
 * AdvSearch
 *
 * Copyright 2012 by Coroico <[email protected]>
 *
 * Query hook 
 *
 */

/*
  Main class:

    package - The name of the schema Package to add. e.g: dvd
    packagePath - The path to the model/ directory where the package is located. Use {core_path} as generic variable.
    class - The class name of the table you want to search. e.g: dvd

    and optionally (these parameters could be passed thru the snippet call):

    withFields - A comma-separated list of column names where to search.
	fields - A comma-separated list of column names to display. 
	ids - A comma-separated list of primary keys to filter where the search should occurs.
    where - criteria or Array of criteria. e.g: "studio IN ('20th Century Fox','DreamWorks Home Ent.','Warner Bros') "
	sortby - csv list of couple 'columnName (ASC| DESC)'.
*/


$main = array(
    'package' => 'lettings',
    'packagePath' => '{core_path}components/lettings/model/', 
    'class' => 'Lettings', 
    'fields' => 'feature_image , street , town , county , price , bedrooms , property_type , heating , furnish , availability , status', // displayed 
    'withFields' => 'property_name , town , bedrooms , property_type , generic_property_type , bedrooms , price', // where we do the search
    'where' => '(`Lettings`.`published` = 1)',
	'sortby' => 'Lettings.price DESC',
	'tablePrefix' => 'tls_'
);

$andConditions = array(
    'Lettings.town:=' => 'town:request:all',
    'Lettings.generic_property_type:=' => 'generic_property_type:request:all',
    'Lettings.price:>=' => 'min-price:request:none',
    'Lettings.price:<=' => 'max-price:request:none',
    'Lettings.bedrooms:=' => 'bedrooms:request:all'
);

//$main['tablePrefix'] = 'modx_';


// set the query hook declaration
$qhDeclaration = array(
    'qhVersion' => '1.2',       // version of queryHook - to manage futures changes
	'main' => $main,
	'andConditions' => $andConditions
);

$hook->setQueryHook($qhDeclaration);
return true;

And the extract from the chunk:

<div class="property-highlight">
	<div class="sq-highlight"><p>Property Type: [[+advsearch.property_type:ucwords]]</p></div>
	<div class="bed-highlight"><p>[[+advsearch.bedrooms:is=`1`:then=`1 bedroom`:else=`[[+advsearch.bedrooms]] bedrooms`]]</p></div>

</div>
<div class="property-highlight">
    <div class="heating-highlight"><p>[[+advsearch.heating]]</p></div>
	<div class="furnished-highlight"><p>[[+advsearch.furnish]]</p></div>
</div>
<div class="property-highlight">
	<div class="availablity-highlight"><p><span>Availability</span>: [[+advsearch.availability:strtotime:date=`%e %b %Y`]]</p></div>
</div>

By the way, which chunk is it from?

@crimsonpixel
Copy link
Author

crimsonpixel commented May 7, 2020 via email

@crimsonpixel
Copy link
Author

Ended up rolling back to version 1.0.1 as I need the chunk to render the results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants