MT:Entries not returning results correctly on search page - movabletype

I'm building out a search results page within a blog. I've rewritten the URL so that going to:
/blog/tag/foo
will return a search results for foo.
In the template, I'd like to return a listing of all the posts that are tagged with 'foo', so I've made an MT:Entries block that starts:
<mt:Entries tag="<$mt:SearchString$>">
but it returns no results. However, placing on the page outputs 'foo' just fine.
So I tried this:
<mt:Entries tag="foo">
and it returns all results correctly that are tagged with foo. I'm not seeing a reason why the other one should work -- any ideas?

You cannot use a tag as a parameter value. You'll have to pass it via a variable, like so:
<mt:setvarblock name="q"><$mt:SearchString$></mt:setvarblock>
<mt:Entries tag="$q">

The reason why <mt:Entries tag="foo"> worked is because you are telling Movable Type to explicitly grab the entries tagged "foo". This is how you should do it in most templates, however the Search Results system template is different.
While the example Francois offers should work, it's not the intended method to get "tag search" results in the Search Results system template.
In the Search Results template, instead of the <mt:Entries> block tag use the <mt:SearchResults> block tag.
You code should look something like this:
<mt:SearchResults>
<mt:IfTagSearch>
<!-- Template tags for "tag search" results -->
</mt:IfTagSearch>
<mt:IfStraightSearch>
<!-- Template tags for "text search" results -->
</mt:IfStraightSearch>
</mt:SearchResults>
For a more detailed example, take a look at the code in the default Search Results template in the "Classic Blog" template set (which ships with Movable Type) and modify the working (and tested) code.

Related

Syntax highlighting Markdown via Assemble.io - incomplete

Am I missing something? I have a rendering pipeline set up with assemble.io via an express server and everything is rendering as expected. However, when I add in bracket fences for Markdown there seems to be an issue with the syntax highlighting. It does drop the code into <code> and <pre> tags as expected and when I add in the language identifier after the top fence it does add in the class="language-[LANG] like you would think it would, however, it does nothing to the code within it (e.g. wrapping the tag elements, attributes, important names, etc. in span tags).
Is there a helper I need to add to the pipeline and pass the file through? So far I've tried adding prismjs, but that flattened the entire page into code (not ideal).
Result:
<a href="">this is the link</a>
Expected:
<<span class="some-tag-class">a</span> <span class="some-name-class">href</span>="">this is the link</a>
Looking at the markdown documentation directly or at the assemble.io documentation does no good.
It's clearly listed on the helper-markdown github/npm sites respectivly.

ModX Get Resources not using template

Newbie to modx and I am trying to build an image slider in Modx Revo. I am using Get resources but it does not output the template file. What am I doing wrong? This is my code:
[[getResources?
&resources=`[[*slide-img]]`
&parents=`-1`
&depth=`0`
&limit=`0`
&tpl=`slides`
&sortby=`FIELD(modResource.id,[[*slide-img]])`
&sortdir=`ASC`
&includeTVs=`1` &processTVs=`1` &tvPrefix=`tv.`
]]
From what I understand, you're trying to get all images from ressources in the resource tree. And show them in an image slider.
I guess you will have the javaScript for the image slider already present. So there is how to get the images.
You have a TV called slide-img, right? Good. Make sure it's output format is text.
If you refer to that image inside of a page that carries that TV, you call it like this
<img src="[[*slide-image]]" alt="some Image" />
If you call it in a chunk (what you will do when using getResources), you call the image like this:
<img src="[[+tv.slide-image]]" alt="some Image" />
See the difference? * is for the TV inside of the same page, + is the correct call for a placeholder. So if you're using getResources, it will put everything you query into the placeholders in your microtemplate (we call that chunk in MODX terms)
So your getResources call might look like this:
[[getResources?
&parents=`-1` (the place from where getResources will dig down the tree)
&depth=`0` (how deep will it dig?)
&limit=`0` (only the default 5? no! :) )
&tpl=`slides` (this is your chunk, right?)
&sortby=`FIELD(modResource.id,[[*slide-img]])` (you will sort by the file name and folder, is that right?)
&sortdir=`ASC`
&includeTVs=`1` &processTVs=`1` &tvPrefix=`tv.` (right, right, tv. is already the default value)
]]
getResources is a snippet used primarily to list documents, not images. A document (of type HTML, XML, CSS or JSON, to name a few) is created in the document tree in the manager and represents an example of a resource that you can get with getResources snippet.
Even if it is possible somehow to put an image as a document (which I doubt), it is not a common way anyway. Usually you want to attach an image to a document via template variable of corresponding type. For a slider particularly, you need many images, not one. So, you might need something specific like Gallery Extra to manage and output your images. Check out gallery section too. Note that basic version of MODX you have just installed isn't fully functional. We have to install extras to use MODX properly. Usually I install up to 30 extras.
Also your snippet call looks weird to me:
&resources=`[[*slide-img]]`
I don't know what the content of your template variable slide-img is but it should be a comma-separated list of resource ids like 2,4,6,34. Probably, in your case you have something different like image url and the snippet call silently crashes or just outputs nothing.

Kentico 9 search result transformation

We've noticed a bug when looking at French search results. in the CMS Desk, i've kept the Page Name in English for the French content. The issue is, these are showing on the French results page.
in the transformation, based off the default one, I present the clickable title like this:
<a href='<%# SearchResultUrl() %>' data-type="title" target="_blank" ><%#SearchHighlight(HTMLHelper.HTMLEncode(CMS.ExtendedControls.ControlsHelper.RemoveDynamicControls(DataHelper.GetNotEmpty(Eval("Title"), ""))), "<span class='highLight'>", "</span>")%></a>
Here's my thinking, if the Menu Caption is filled out, use that rather than title. How do i output DocumentMenuCaption without adjust the search fields on the menu page type?
I think my logic is, check if DocumentMenuCaption is emtpy, if it use, use Title.
You should be able to continue using GetNotEmpty and just pass in the DocumentMenuCaption first, something like this:
<%# GetNotEmpty(GetSearchValue("DocumentMenuCaption");Eval("Title")) %>
You may or may not need the "GetSearchValue" function, but that allows you to grab values from the object that may not be available in the default set of columns for the search results.
Alternatively, you should be able to use the IfEmpty() method:
<%# IfEmpty(GetSearchValue("DocumentMenuCaption"), Eval("Title"), GetSearchValue("DocumentMenuCaption")) %>
Both transformation methods taken from here (double check syntax on "GetNotEmpty" as there are different ways it's implemented: https://docs.kentico.com/k9/developing-websites/loading-and-displaying-data-on-websites/writing-transformations/reference-transformation-methods
You can read more about the search transformations here: https://docs.kentico.com/k9/configuring-kentico/setting-up-search-on-your-website/displaying-search-results-using-transformations

Kentico 9 transformation page/file URL

In my custom page type, you can select an uploaded file. That's fine, but in my ascx transformation, i'm having a hard time getting the URL. The field is 'Process'.
Here's what i currently have.
<%# IfEmpty(Eval("Process"),"N/A","<a href=" + Eval("Process") +" target='blank' class='icon download'>Download</a>")%>
When rendered, the html is this:
Download
I'm missing something.
You can use either of the 2 methods below. Both have their downfalls though.
<a href="<%# GetFileUrl("Process", "Something") %>"Link here<a/> this will
Downfall with this is if there is no value in the "Process" field, it will return an invalid URL. So I tend to use something a little better (but not much)
Item to download
This will create a valid URL with some invalid properties to it. Meaning if there is no value in the Process field, it will return 00000000-0000-0000-0000-000000000000. If the NodeAlias field is empty, it will return "download". So again, not 100% fool-proof but it works well in most cases.
Update
Check out this link:
https://devnet.kentico.com/articles/options-for-file-fields-in-structured-data
I think the piece you need in here is in the "CMS.File page type" section:
This is the link to the picture
Check out transformation methods reference
You can use <%#GetImage(Eval("Process"))%>. This will return an Image tag. There are a couple other parameters for sizing if you want to use those.
See the "Transformation reference" link on your Trasnformation editor, it goes to all the available transformation methods you can use.
In it it shows:
This will generate an actual image tag. If however you want a link, it usually is
/getattachment/<%# Eval("TheImage")%>/ImageFileNameCanBeAnythingThough.jpg
example:
/getattachment/1936c69d-a28c-428a-90a7-09154918da0f/Christmas.jpg

Inner tags not parsing with Expression Engine 2 custom plugin

I've written a simple plugin that basically loops through a bunch of entries. The plugin is used to only display entries that contain a feature image, amongst some other minor logical conditions. The use of my tag looks something like this:
{exp:myentries:withimages channel="mychannel"}
<!-- This works fine -->
<h1>{title}</h1>
<!-- But nested exp:... tags don't seem to parse? -->
<p>{exp:ce_img:single src="feature_image"}</p>
{/exp:myentries:withimages}
I am calling
return $this->EE->TMPL->parse_variables($this->EE->TMPL->tagdata, $data);
from my custom EE plugin, the data is there, but only the nested {exp:... tags don't want to parse.
I've followed the online User Guide for creating plugins as close as I possibly could, but I need some help getting the other tags to parse? If I simply output {feature_image}, the field renders the src value for the image as expected.
Can anyone possibly shed some light on what I'm doing wrong?
You want to put parse="inward" parameter in your {exp:myentries:withimages tag, otherwise the template will try to parse the exp:ce_img call before {feature_image} is set.
{exp:myentries:withimages parse="inward" channel="mychannel"}
The parse="inward" will tell EE to run this tag first before parsing any other tags within the tag pair.
There are two important typos in your code.
{exp:ce_img:singe src="feature_image"}
Should read:
{exp:ce_img:single src="{feature_image}"}
If those differences are actually present in your template, then that would be it I believe.

Resources