• I am trying to find a way to add a calendar to a page that changes for each customer file. This is on a rental property site and the calendar show availability. See working example here. https://thevillagesideas.com/rentals/a-rental-in-the-villages-florida/

    The code that shows the calendar looks like this..

    <script type=”text/javascript” src=”//www.availabilitycalendar.com/embed-js/eedyWfd9i9d8yN7te1gz/en-0-0-1-1-0-0-0-0-0/”></script>

    I would like to make this a PHP function with a custom variable used to supply the one piece of information that changes which is the file identifier (eedyWfd9i9d8yN7te1gz) from the example above.

    1. I need a way to store the variable, eedyWfd9i9d8yN7te1gz (from above)

    2. I need the PH code to retrieve the variable, insert it in the code above (<script type=”text/javascript” src=”//www.availabilitycalendar.com/embed-js/eedyWfd9i9d8yN7te1gz/en-0-0-1-1-0-0-0-0-0/”></script>)

    3. Display the calendar at the top of the content page.

    Again the calendar variable changes for each property listed in the database.

    Any help would be appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • JavaScript and PHP operate in two completely different ways. PHP is executed on the server, and by the time you see the webpage, the code has already been executed. JavaScript, instead, is executed by the browser on page load and subsequently.

    This means that by the time your browser loads the JavaScript code that you need, the PHP code has already finished being executed.

    As far as I can see your calendar is generated by availabilitycalendar.com and I would suggest asking their support team whether their software can provide you with a code that you can use during the PHP execution.

    I think you will be able to do what you want with a shortcode in your page or post.

    So in your example you could have this text in your post:

    [avail id="eedyWfd9i9d8yN7te1gz"]

    Your registered shortcode function would translate this into your code:
    ‘<script type=”text/javascript” src=”//www.availabilitycalendar.com/embed-js/eedyWfd9i9d8yN7te1gz/en-0-0-1-1-0-0-0-0-0/”></script>’
    Here are the details on the shortcode technique.
    IMPORTANT: Your shortcode function RETURNS the replacement text, it does NOT echo anything itself. I mention this because it is an easy trap to fall into.

    https://codex.www.ads-software.com/Shortcode_API

    Presumably you will use css to position the calendar.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding Custom Information to a wordpress page’ is closed to new replies.