• Resolved cjmclean

    (@cjmclean)


    This is a follow-on from the previous post but I’m opening a new thread because it is a slightly different vein.

    Firstly, I’d like to state that I’m not proficient in PHP. In fact, my understanding of PHP is rather basic but I’m a quick learner.

    As per my pervious posts, I’ve created a link-table and managed to display it with the following shortcode:

    [if cast_and_role]<strong><u>Cast:</u></strong> 
    <ul>[each cast_and_role]
    	<li><a href="{@permalink,esc_url}">{@related_actors}</a> as {@related_characters}</li>[/each]</ul>[/if]

    As you can see, I’ve tried to create a link for my ACTOR field. However, when I click the link on the front page, the page just refreshes which I’m assuming is because the url doesn’t really take it anywhere. I would like to direct the link to the post it is related to.

    Is it possible to do this with just shortcode alone and, if so, how do I go about this?
    I’ve tried several options using the shortcode examples in https://docs.pods.io/code-snippets/build-anything-with-pods-pods-template-examples/ but with no success.

    If I do need to add PHP to the shortcode, where would I put it?

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

    (@keraweb)

    Hi @cjmclean

    Your code now refers to the cast_and_role Pod for the permalink, this is incorrect.

    It should point to the actor within the cast_and_role for the permalink.

    Example: {@actor_rel_field.permalink,esc_url}.

    Also, I still don’t think you fully understand a the concept of this structure.
    Each cast_and_role Pod should only have 1 actor and role. I now see a {@related_actors} field which doesn’t make any sense.

    Cheers, Jory

    Thread Starter cjmclean

    (@cjmclean)

    I’ve changed the coding as per your suggestion but it’s still showing the same result.

    [if cast_and_role]<strong><u>Cast:</u></strong> 
    <ul>[each cast_and_role]
    	<li><a href="{@related_actor.permalink,esc_url}">{@related_actor}</a> as {@related_character}</li>[/each]</ul>[/if]<br>
    • This reply was modified 4 years ago by cjmclean.
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hello @cjmclean

    The code you’ve posts looks good to me so I’m not sure what might be wrong there.
    The Actor pod is public?
    It is showing the actor Name/Title?

    Cheers, Jory

    Thread Starter cjmclean

    (@cjmclean)

    Yes, to both questions.

    Thread Starter cjmclean

    (@cjmclean)

    As an experiment, I changed the code slightly to include my website url with this:

    [if cast_and_role]<strong><u>Cast:</u></strong> 
    <ul>[each cast_and_role]
    	<li><a href="/actor/{@related_actor}">{@related_actor}</a> as {@related_character}</li>
    	[/each]</ul>[/if]

    What I ended up when i clicked on the link was a re-direction to a “Page not found” with this URL

    https://www.mydomain.com/actor/firstname%20lastname/

    The URL itself is very close to what I need except it should be https://www.mydomain.com/actor/firstname-lastname/ with – instead of %20.

    Any thoughts?

    • This reply was modified 4 years ago by cjmclean.
    • This reply was modified 4 years ago by cjmclean.
    • This reply was modified 4 years ago by cjmclean.
    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @cjmclean

    The last code you’ve posts is incorrect in that case.
    If the actor title is shown then {@related_actor.permalink} should work just fine. This should be the full value of the href attribute.

    Cheers, Jory

    Thread Starter cjmclean

    (@cjmclean)

    Thank you! After taking your advise into account, the link now works.

    • This reply was modified 4 years ago by cjmclean.
    Plugin Author Jory Hogeveen

    (@keraweb)

    You’re welcome! The best way to say thanks is to leave a 5 star review at https://www.ads-software.com/plugins/pods/ and (if you’re feeling especially generous) become a Friend of Pods at https://friends.pods.io/

    Cheers, Jory

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘URL link to post’ is closed to new replies.