• Resolved xuzo

    (@xuzo)


    I see that there are 2 boxes, in the advanced tab:

    Set Default Values

    AND

    Set Default Value via Parameter

    I’m trying to do 3 things:

    – Display default image if no featured image is selected
    – Display default text if no text is selected
    – Display custom HTML pod if no HTML is pasted

    It would be great to know what code I’m supposed to input in those fields?

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @xuzo

    I’ll make a short overview for you!

    – Display default image if no featured image is selected
    The image ID

    – Display default text if no text is selected
    The actual text

    – Display custom HTML pod if no HTML is pasted
    The actual HTML (assuming it’s an HTML field)

    “Set Default Value via Parameter” > This stands for a GET parameter.

    Cheers, Jory

    Thread Starter xuzo

    (@xuzo)

    Thank you!

    However I think I worded the question wrong.

    What I mean is not only for the content to show up in backend by default, but also on front end by default.

    So say the item has a no featured image selected, a default featured image will show up on front end.

    So kind of like this:

    IF field has no value, assign X value, on front end.

    Thanks

    Thread Starter xuzo

    (@xuzo)

    I tried this:

    Settings for default image

    But it’s not working, I input:

    `Default Value:
    11099

    Set Default Value Via Parameter:
    GET

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @xuzo

    What I mean is not only for the content to show up in backend by default, but also on front end by default.

    This cannot be done with this setting. This setting is only used for newly created objects upon save. After the initial save the default value won’t do anything anymore.

    The default value via parameter also works different.
    You can set this to a field name from your url.
    Example: domain.com/edit.php?parameter_name=11099
    Then you could set the parameter setting value to parameter_name.

    IF you need actual default handling if the value is (for example) empty (or false) you’ll need to use if statements in your template code.

    Cheers, Jory

    Thread Starter xuzo

    (@xuzo)

    I know this is asking a lot, but I’m totally lost…

    So I need to add php to my themes template or can I ad the php in a pods template?

    What about as shortcode in Gutenberg blocks?

    Can you paste the entire PHP code here, so I can copy it and try to modify it so I can use it?

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @xuzo

    In case you use our Pod templates tool then please read our documentation on template tags: https://docs.pods.io/displaying-pods/template-tags/
    Especially the lings below this page to more detailed info.

    In case of PHP the syntax isn’t that different:
    https://www.w3schools.com/php/php_if_else.asp
    Though you need to fetch the field information.
    https://docs.pods.io/code/pods/field/

    Cheers, Jory

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to display default pods content if empty?’ is closed to new replies.