• Resolved ljkeashly

    (@ljkeashly)


    Hi,

    I have a page with this post snippet on it:
    [form1 page="abc"]

    Because the form is so long and complex I have it in a php file, so in the Post Snippet I have:
    include('content/form1.php');

    Now in form1.php I want to put the value of the ‘page’ variable in a hidden form field. Using {page} in the php file doesn’t work. How do I access the variable in the php code? Is it possible?

    Thank you.

    https://www.ads-software.com/plugins/post-snippets/

Viewing 2 replies - 1 through 2 (of 2 total)
  • How far do you get it working? You get the include file loaded, but not the variable injected?

    Thread Starter ljkeashly

    (@ljkeashly)

    Hi,

    Yes, when I used {page} in the php include file it includes {page} rather than the value of page. So what I did was make a function that has some parameters and wrapped the included code in the function. Doing it this way worked. So, I have:
    include('content/form1.php'); function form1 ({page});

    Now in the included php file I can put form1 function’s parameter anywhere I need and it works.

    Thank you for your response.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to get Post Snippet Variable in php code’ is closed to new replies.