Applying infinite scroll upon wooocmmerece site isn't working as expected - search

I'm trying to implement jetpack's infinite scroll. my website has ?currency_switch=EUR and ?orderby=width-desc these kinds of custom URL parameters, which are successfully implemented without any ajax and for search I am using relevanssi.
I am using this code in my functions.php
function mytheme_infinite_scroll_init() {
add_theme_support( 'infinite-scroll', array(
'container' => 'multiple-products',
'type' => 'scroll',
'posts_per_page' => get_option( 'posts_per_page' )
) );
}
add_action( 'init', 'mytheme_infinite_scroll_init' );
It works (only at the shop page) but doesn't work with the custom url parameters as mentioned above and breaks for search.I didn't tweak any code for pagination(didn't alter any $paged stc).
How to handle it for custom query params? How to deal with relevanssi as it states that it doesn't support the jet pack plugin's infinite scroll feature, is there a way to make relevanssi results infinite scrollable via jet pack.
I tried my custom implementation , as a start tried making a simple ajax call but i am ending up with weird issues like this A simple Ajax call in wordpress doesn't give the expecetd output
Thanks

Sorry for the boring answer, but there's no way to make Relevanssi work with the Jetpack Infinite Scroll feature. You just need to disable it on search pages, as described in Relevanssi knowledge base.

Related

Kentico Widgets :: Matching fields with HTML structure of Web Part

I really hope I'm making sense with this one.
I'm trying to create a widget from a custom webpart that I created. It's nothing special at all as you can see:
<h3>Header</h3>
<p>Intro Copy</p>
<ul>
<li>List item one</li>
<li>List item two</li>
<li>List item three</li>
</ul>
I now want to be able to create a widget from this and create new fields that will be used to populate the above DOM. What do I need to do in order or do this.
In an example I saw for the demo site, they populated the bg image with:
style="background-image: url('{% ResolveUrl(PathToImage) %}');"
That was however done on the front facing part of the CMS and I'm trying to do it within the solution.
Any thoughts?
It's all in your layout or code behind. Your layout can have that code (but in ASCX format) and it will work just fine. OR you can add literal controls to the page based on the fields and what the user has entered.
Doing it in your layout is more restrictive and specific to that one application but allows you to use multiple new webpart layouts. Using the code approach allows you to be more dynamic but doesn't allow you to use the built-in layouts of the webpart/widget.
I would just use the Transformable Web Part in the Marketplace...it does exactly what you want it to do. Create a custom web part, and you use a Transformation to style the Web Part Properties into the DOM elements.
https://devnet.kentico.com/marketplace/web-parts/transformable-web-part
Reason why i built it!
I've done something similar in the past, using what I call generic web parts. I wrote a blog on it last year - it might help out with what I think you're trying to achieve:
http://www.mattnield.co.uk/Posts/Show/generic_web_parts_for_rapid_development
Why are you choosing to go with Widgets? If you want to access any field inside the transformation within the web part it's feasible by the same way as you define in inbuilt web parts.
If you want to perform any function like onload etc. then you need to use kentico API to access any data.
If you provide more insight on what is required, I can help further

Override Detail template for a Content Type with url alternate in Orchard CMS

Does anyone know if it's possible to override the DisplayType template for a ContentType using the an url alternate template? For example, is it possible to override the template:
Content-Page.Detail.cshtml with Content-url-homepage-Page.Detail.cshtml? After playing around a bit, it does not seem so. Does anyone know if what I'm trying to achive is possible?
Thanks!
You can view all available alternates for a shape by enabling the 'Shape Tracing' feature and viewing the list of alternates e.g. http://devhammer.net/blog/Customize-Orchard-CMS-with-Designer-Tools
For example on the main content item of the homepage I get out of the box:
~/Themes/MyTheme/Views/Content.cshtml
~/Themes/MyTheme/Views/Content-url-homepage.cshtml
~/Themes/MyTheme/Views/Content.Detail.cshtml
~/Themes/MyTheme/Views/Content-Page.cshtml
~/Themes/MyTheme/Views/Content-10.cshtml
~/Themes/MyTheme/Views/Content-Page.Detail.cshtml
~/Themes/MyTheme/Views/Content-10.Detail.cshtml
Your options are to add or extend existing alternate factories such as Orchard.DesignerTools.Services.UrlAlternatesFactory e.g.
// appends [ShapeType]__url__[Url]_[DisplayType] alternates
context.ShapeMetadata.Alternates = _urlAlternates.Value.Select(url =>
context.ShapeMetadata.Type + "__url__" + url + "_" +
context.ShapeMetadata.DisplayType)
.Union(context.ShapeMetadata.Alternates)
.ToList();
This will give you the alternate
~/Themes/MyTheme/Views/Content-url-homepage.Detail.cshtml
or to use one of the existing alternates such as
~/Themes/MyTheme/Views/Content-10.Detail.cshtml
Which looks like it might suit your purposes (to me using the id is not as clean as using the url)
I also tried adjusting the feature priority of the 'Url Alternates' feature so that the url alternates are appended to all the other existing alternates as it appears from the code was intended, but as far as I can see this is not working or otherwise not supported.

CakePHP 2 Pagination woes

I am having a problem getting the precise URL needed when using pagination in CakePHP 2.1.3 which needs to be the same as my custom route. Here is an example of what I have:
URL: /courses/section-name/cat-name/subcat-name
My route:
Router::connect('/courses/:section/:cat/:subcat/*', array(
'controller' => 'courses', 'action' => 'courseCategory'), array(
'pass' => array('section', 'cat', 'subcat'),
'section' => '[a-zA-Z0-9_-]+',
'cat' => '[a-zA-Z0-9_-]+',
'subcat' => '[a-zA-Z0-9_-]+'
));
Everything works fine in terms of normal navigation using this format and when visiting a page I get paginated results okay with all my links etc. I have set my Paginator Helper 'options' as follows:
$this->Paginator->options(array('url'=>$this->passedArgs));
This however produces a URL like eg: /courses/courseCategory/section-name/cat-name/subcat-name/page:2 which does not work.
If I manually remove the action name 'courseCategory' from the URL eg: /courses/section-name/cat-name/subcat-name/page:2 etc, then everything works fine and I go to the relevant page of results, so I guess I am close? However, after many hours of searching, reading the docs/API and trying different things I just cannot get my URL links to appear without the controller's action and it's now driving me mad!
So, I guess the question is either where am I going wrong or does anybody have an alternative solution to this?
Any help would be greatly appreciated & happy to provide more info if needed.
Thanks :)

Inserting a news-feed widget to a page

I have a page I'd like to embed a news-feed widget into (so that the feed from some remote site will be displayed in my site).
While there are quite a few free news-feed widgets available out there (a partial list is here: http://allwebco-templates.com/support/S_script_newsfeed.htm), They all require insertion of complex code into the html page, while all the parameters are hard-coded into the generated code, which looks something like this:
insertedWidgetText = "<script id=\"scrnewsblock10795953\" type=\"text/javascript\">...script specific parameters go here...</script>"
let feedWidget = toWidgetBody [hamlet|#{preEscapedText insertedWidgetText}|]
This doesn't integrate well with Yesod's approach as it requires specifying to Hamlet that the content is preEscapedText, which in turn disables the ability to use Hamlet's processing to alter parameters of the widget dynamically (So in case I want the widget to use a different source, for example, I need to statically change the quoted text and cannot use Hamlet's variable substitution).
Of course I could do some text manipulation myself, tailor built for the widget I'm using, but that doesn't seem like the "right" solution (especially if I want to have the embedded text in some external file and not in the middle of my code as in the example above).
Can the above mentioned issue have a better solution than the one I thought about?
Is there an implementation of a news-feed widget in Haskell/Yesod that I can use as a plugin?
Note: I'm a very poor javascript programmer, but solutions in that direction are also welcomed.
Thanks,

Webmatrix Layout -- Inserting into head?

I've created a web site using Asp.Net and the Razor view engine (which is the same as using WebMatrix). Up to now, I've been using SQL to query databases directly, but now I have a page which needs to query a WCF service that returns XML (getting that to return JSON or ODATA maybe is for a separate question).
On doing this, I was looking at the best way to do this, and it seems that jQuery may be the answer (unless you have other thoughts).
The problem is I'm using SiteLayout using the Layout="~/SiteLayout.cshtml" and I can't work out how to override or insert extra information specific to this page into the head tag that is in the SiteLayout, such as the script I need to add?
I'm pretty sure I'm thinking about this wrong, so if anyone has the answer to point me in the right direction, that would be great.
Thanks in advance for any assistance.
You can to define a Head section in the child pages:
#section Head {
<script> ... </script>
}
You can then call RenderSection("Head") in the <head> in the layout page to render this section.
You may want to pass , required: false.
For more information, see ScottGu's blog post

Resources