• Resolved vi54

    (@vi54)


    When I use pods shortcodes in salient theme’s shortcodes, this usually works wonders.

    However.
    Not with: [if] [/if]

    [if personal]
    	<h6>My Preferences:</h6>
    [fancy-ul icon_type="standard_dash" color="Accent-Color" alignment="left" spacing="5px" enable_animation="true" link_style="default"]
    {@personal}
    [/fancy-ul]
    [/if]

    This breaks the salient shortcode fancy-ul.


    When I break it up: an if around the H6, and and if around the fancy-ul’s content, that works but it creates unnecessary <p> and <br>’s

    <div class="nectar-fancy-ul animated-in" data-list-icon="icon-salient-thin-line" data-animation="true" data-animation-delay="0" data-color="accent-color" data-spacing="5px" data-alignment="left"> <p></p>
    <ul>
    <li aria-level="4" style="opacity: 1; left: 0px;"><i class="icon-default-style icon-salient-thin-line accent-color"></i> my item one</li>
    <li aria-level="4" style="opacity: 1; left: 0px;"><i class="icon-default-style icon-salient-thin-line accent-color"></i> my item two</li>
    </ul>
    <p> </p></div>

    Hope this can be resolved?

    Thank you

    • This topic was modified 8 months, 1 week ago by vi54.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Scott Kingsley Clark

    (@sc0ttkclark)

    Where are you using the [if] shortcode exactly?

    Thread Starter vi54

    (@vi54)

    inside the pod template editor

    Plugin Contributor Scott Kingsley Clark

    (@sc0ttkclark)

    It looks like the way our shortcode runs it is adding that formatting to the [fancy-ul] shortcode output or something else is going on there. I don’t see where this is happening on Pods’ side and I don’t have a way to reproduce this as that is a non www.remarpro.com theme.

    Plugin Support Paul Clark

    (@pdclark)

    Shortcodes and template magic tags and conditions are executed in different contexts, which can cause challenges with race conditions and formatting, as both are markup languages unaware of many variables and contexts available to programming languages.

    The simplest workaround for complex recursion and conditionals which need to pass information to shortcodes etc. is to define a shortcode for use in the template. For example, [if_personal_fancy_preferences]

    <?php
    add_shortcode(
      'if_personal_fancy_preferences',
      function( $atts, $content, $tagname ) {
        $personal = pods()->field( 'personal' ); // Auto-detecting the pod type... Might be a user or a post.
        if ( ! empty( $personal ) ) {
          return '<h6>My Preferences:</h6>' . apply_shortcodes(
            sprintf(
              '[fancy-ul icon_type="standard_dash" color="Accent-Color" alignment="left" spacing="5px" enable_animation="true" link_style="default"]%s[/fancy-ul]',
              $personal
            )
          );
        }
        return '';
      }
    );

    Thread Starter vi54

    (@vi54)

    That is awesome! Learning everyday.

    I had to adapt it a bit to make it work, but I understood the idea behind it.

    function preferences_code(){
    	$personal = pods()->field( 'personal' ); // Auto-detecting the pod type... Might be a user or a post.
     	if ( ! empty( $personal ) ) {
        	return '<h6>>My Preferences:</h6>' . apply_shortcodes(
            	sprintf(
              		'[fancy-ul icon_type="standard_dash" color="Accent-Color" alignment="left" spacing="5px" enable_animation="true" link_style="default"]%s[/fancy-ul]',
              	$personal
            	)
          	);
        }
    }
    add_shortcode('preferences_fancy', 'preferences_code');
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Pods shortcode inside shortcode: odd behavior’ is closed to new replies.