Problems with asset_contents Keyword Modifyers 3.26.2


(Acallaghan) #1

Hi,


We have recently upgraded to 3.26.2



We understand it fixes a bug with earlier Matrix versions where keyword modifyers would not work with %asset_contents%.



Keyword modifyers do now display content when used on %asset_contents% however there seems to be a problem with the html output.



I thought it was our design but am not sure now as have tested with an unmodified downloaded design as follows:


  • create a new site and apply 'localise' design.
  • create a number of standard pages
  • create an asset listing page displaying standard page assets using %asset_contents%
  • page structure is ok:






  • change the asset listing to show %asset_contents^maxwords:15% instead of %asset_contents%
  • 15 words of each page are displayed however page structure is no longer ok - e.g. footer div is embedded into page content:







    From what I can see there are now too many <div> entries in the section where the keyword modifyer content is displayed.



    Any ideas?



    Thanks!

(Dan Simmons) #2

I'd say that's probably occurring because by using ^maxwords, you're cutting off the closing DIV tags in your content which malforms your HTML.


I'd suggest to try and restructure your markup in such a way so that the asset listing in which you print with ^maxwords strictly only contains text content (with no HTML tags).


(Acallaghan) #3

Thanks Dan, I tried modifying the asset listing by creating multiple divs so that I have separate div for my html above and below and then using a raw html div for the %asset_contents^maxwords:xx% (ensuring there is no other html at all in this div.


I am guessing this is not quite what you meant? (it didn't work).



As far as having an asset listing without any html at all not quite sure how to go about this!?



Is this behaviour expected? Things work fine if I am use keyword modifyers on metadata instead of asset_contents for example.


(Nic Hubbard) #4

[quote]
Thanks Dan, I tried modifying the asset listing by creating multiple divs so that I have separate div for my html above and below and then using a raw html div for the %asset_contents^maxwords:xx% (ensuring there is no other html at all in this div.



I am guessing this is not quite what you meant? (it didn't work).



As far as having an asset listing without any html at all not quite sure how to go about this!?



Is this behaviour expected? Things work fine if I am use keyword modifyers on metadata instead of asset_contents for example.

[/quote]



Asset contents is going to be everything from an asset that is listed with an asset listing. So, even if you created a div above and below, that is not really going to matter. It is still going to truncate your html, because that is what you are telling it to do.



I think in this case, you might want to use something like jQuery, that can truncate the text INSIDE your html, rather than the entire html string itself.



Do you have to use asset contents? What kind of asset are you listing?


(Acallaghan) #5

[quote]
Asset contents is going to be everything from an asset that is listed with an asset listing. So, even if you created a div above and below, that is not really going to matter. It is still going to truncate your html, because that is what you are telling it to do.



I think in this case, you might want to use something like jQuery, that can truncate the text INSIDE your html, rather than the entire html string itself.



Do you have to use asset contents? What kind of asset are you listing?

[/quote]



Sounds like I have misunderstoon asset_contents then - I thought it was just the text content of an asset. What I am trying to do is have standard pages (which I am using as featured articles for a news type site) and have an asset listing on the home page which displays summaries of each featured article. So I really just want to truncate the default div content for each standard page but it is sounding like asset_contents includes much more than that.



My current workaround is an article summary metadata field which works fine (although a little more effort needed creating articles) unless there is a better way I have missed?



Thanks!


(Luke Wright) #6

Hi,


You can chain keyword modifiers together; you could possibly use the "strip HTML" modifier before you summarise it, something like:

%asset_contents^striphtml^maxwords:15%



I haven't tried this myself however it should get you closer to what you are looking for.


(Acallaghan) #7

[quote]
Hi,



You can chain keyword modifiers together; you could possibly use the "strip HTML" modifier before you summarise it, something like:

%asset_contents^striphtml^maxwords:15%



I haven't tried this myself however it should get you closer to what you are looking for.

[/quote]



Thanks Luke! This works!


(Luke Wright) #8

You're welcome. :slight_smile: Glad to see it's working now.


(Amurray) #9

Thanks so much! That ^striphtml^maxwords:15% can be added to so many variations! Worked a charm!