I'm trying to set the URL of my product entry's to be dynamically created based on 3 category fields and 2 number fields. The category fields are required, but I need to add some logic for the number fields.

It's all taking up so much space that upon saving the section's settings, the URL Format field cuts off some of my code. I'm sure there is a great reason that this field has a character limit so is there anything else I can do? I tried importing a macro, but couldn't get that to work. Do I have to create a plugin?

This is the content I need to use in my Entry URL Format that is too long with my variable names:

some-text-here/{%if object.mfgCategory.first.slug=="1hack"%}hack{%else%}{mfgCategory.first.slug}{%endif%}-{%for c in object.series%}{c.slug}-{%endfor%}{sizeCategory.first.slug}-{%if object.num1=='0'%}00{%else%}{number1}{%endif%}-{%if object.number2=='0'%}00{%else%}{number2}{%endif%}

2 Answers 2


One thing that might help is to use the Ternary Operator described here:




instead of:

{%if object.mfgCategory.first.slug=="1hack"%}hack{%else%}{mfgCategory.first.slug}{%endif%}

It's slightly shorter so might help a bit.


You could refactor it using ternary syntax and see if it fits. Otherwise you could also do it with a plugin and listen to beforeSaveEntry events.

  • Thanks for the help! I used the ternary syntax and shortened some field handles to keep from having to use a plugin.
    – Chandra
    Apr 24, 2015 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.