Keyword Modifier Using maxchars


(Nick Papadatos) #1

Matrix Version:
5.4.3.2

Hi - can someone assist me when using %asset_metadata_post_content^maxchars:300% keyword modifier?
The post_content is a WYSIWIG metadata type.

Issue:
Adding the ^maxchars:300 breaks the page completely.

Cheers
Nick


(Nick Papadatos) #2

I think I know why/what’s happening but I just need clarification:
The maxchar is including HTML characters and if there are unclosed tags missing then your page gets all skewed, correct?

Is there another way to fix this issue i.e; ignore HTML characters using maxchars?

Regards
N


(Tim Trodd) #3

Hi Nick,

Is this for a summary of that field rather than displaying the whole field itself?

If so, do you need it to display the html? e.g. for a news page we might display the whole metadata field on the actual story page including the html, but in the listing we strip the html followed by using the max chars. So in your case it would be:

%asset_metadata_post_content^striphtml^maxchars:300%

If you do need to print the html aswell, you might need to use something like jQuery truncate instead and display the field as normal and truncate the innertext in it instead.

Tim


(Nick Papadatos) #4

Thanks Tim

Found what I was looking for here

I didn’t realise the striphtml: <allowable tags> was available:

%asset_metadata_post_content^striphtml:<p>^maxchars:300%...

You can optionally pass the <allowable tags> argument to restrict the modifier from removing certain HTML tags. :-0

Regards
Nick