Dynamic hyperlinks

Dynamic hyperlinks is a feature that allows plugin users to add hyperlinks to tables and views. A dynamic hyperlink is generated on the fly. Column variables can be added to a hyperlink and are substituted on generation.

Example

To add a dynamic hyperlink to a table or view:

  • Start the Data Explorer
  • Click on the Manage link of the table or view to which you want to add the hyperlink
  • Click on Dynamic Hyperlinks
  • Add your hyperlink(s)
  • Save your hyperlink(s)

See example below (click to enlarge)

  • The plugin allows to add multiple hyperlinks to a table
  • The links are added to the end of the table or view in the Data Explorer
  • The links are added to the end of the table or view in a Data Project (this will be changed later)
  • The Data Publisher allows you to put hyperlinks on any position

Hyperlink Settings

Hyperlink Label

Column label in a list or on a form.

+List?

Enable if hyperlink should be shown in lists.

+Form?

Enable if hyperlink should be shown in forms.

+Window?

Enable if hyperlink should be opened in a new tab or window.

HTML

Add a URL(like https://your-domain/) or add your own HTML including one or more hyperlinks. If you just add a URL, the plugin will use the Hyperlink Label and +Windows? settings. Otherwise the plugin uses your HTML code.

Add your own HTML if you want to:

  • add multiple hyperlinks in one column
  • use icons in your hyperlinks instead of the label text
  • your own HTML to this column

Column Value Substitution

To use column values in a hyperlink simply add the column name between $$ to your URL or HTML. In the example below the variable $$id$$ is substituted with the value for column id. Column id must be a column of the table for which the hyperlink is created.

https://your-domain/service.php?id=$$id$$

Data Publisher Example

To add a hyperlink to a publication:

  • Edit the publication
  • Click on button “Select”
  • Add your columns and hyperlinks to the list on the right side
  • Save your publication

The example below (click to enlarge) uses HTML to show multiple hyperlinks in one column as icons.

Peter Schulz is a lecturer in information technology at the HAN university of applied sciences. He is an experienced programmer with more than 25 years experience in Oracle databases and tools. Peter is the developer of WordPress plugin WP Data Access.

6 Replies to “Dynamic hyperlinks”

  1. Hi Peter,

    so my suggestion is: If I use a Dynamic Hyperlink and use a link like: http://127.0.0.1/wordpress/test-page/ and I want to add the column information from “my_id” then my link is: “http://127.0.0.1/wordpress/test-page?my_id=$$my_id$$” correct?

    Next I want to use the my_id information in a shortcode from a datapublisher-page to filter the table entries there. Is that even possible?
    If not, how can I use the Dynamic-Link-Information to get data from a table and display that on a custom wordpress page or post?

    Thank you so much! I have the impression that I’m missing some connections in how these value substitutions work..

    Have a nice day,
    Chiara

  2. Hi Chiara,

    Your suggestion is correct! That’s is exactly how dynamic hyperlinks (value substitutions) are meant to be use. 😉

    It should be possible to use argument my_id in your publication as well, but I haven’t tested it. Please check out this options to define an initial search on a specific column:
    https://datatables.net/reference/option/searchCols

    Within the plugin you can use filter wpda_wpdataaccess_prepare to read the url argument and write its value to a javascript variables, which can then be used in your initial search. Here is some information about filter wpda_wpdataaccess_prepare:
    https://wpdataaccess.com/2020/03/25/filter-wpda-wpdataaccess-prepare-to-add-custom-options-to-a-publication/

    In your use case you might also want to disable a global search. You can use the dom option to do this:
    https://datatables.net/reference/option/dom

    Looks like you’re building a complete application with a flow from data entry until data publication? Great! 🙂 Let me know if you help…

    Best wishes,
    Peter

    1. Good Morning Peter,

      yesterday I’ve tried to understand, how this could work out, but I didn’t made much progress.

      First question: where do I have to edit the filter wpdata_wpdataaccess? Is the filter integrated in the plugin-files somewhere or can I use it directly in the plugin-frontend on wordpress somehow?

      Second question: when I did the dynamic hyperlink with “http://127.0.0.1/wordpress/test-page?my_id=$$my_id$$” and then click on this in a row of my published table the link I get is: “http://127.0.0.1/wordpress/test-page/?my_id=$$my_id$$”. There is no value substitution happening. Do I have to add more information to the dynamic link or what is going wrong here? Is there a problem because my “test-page” is a wordpress page and has no extension “.php”?

      Thrid question: how can I then connect the filter wpdata_wpdataaccess_prepare with my publication?

      I would be so glad, if you could do a short tutorial or something to this issue. Something like “how can I add a dynamic link to a publicated table, which links to a page, where I filter data from a table and show only a picture or the price of the product and not all detail-information?”
      If you don’t have the time to do a tutorial, i totally understand that.

      Thank you sooo much for your support! Don’t know, what I would do without your constant, helpful support!

      Chiara

      1. Hi Chiara,

        Let’s start with the dynamic hyperlink. Does your table have a column my_id? The plugin will only substitute values for existing column names. If your table has no column my_id, nothing happens. Make sure your are writing an existing column name between the $$ characters. For example: use $$student_id$$ to add the student_id to your hyperlink.

        When your hyperlink points to:
        http://127.0.0.1/wordpress/test-page/?my_id=123
        you need to make sure this page exists and is able to handle argument my_id. Your hyperlink can be on the same domain or another domain. So:
        http://www.some-domain.com/index.php?my_id=123
        works as well. Your hyperlink URL does not need to have an extension .php as long as the URL is able to handle the querystring (in this case my_id=123) you are sending.

        Be carefull with the filter! The name of the filter is:
        wpda_wpdataaccess_prepare (not: wpdata_wpdataaccess_prepare)

        To add a filter, you need to put your PHP code “somewhere”. There are severals ways to do this. One of the most common ways I think is to add your code to the theme function.php file. The disadvantage is that a theme update overwrites your changes.

        I created a plugin add-on – the Code Manager – to add your own hooks and filters in such a way that it survives all types of updates (WordPress, themes and plugins). The add-on is ready, but I do not yet have a sales channel (working on it). I will need to create an instruction video for this add-on anyway, so I’ll try to create a video this week. I hope the video will help you to write your own hooks and filters.

        Best regards,
        Peter

  3. Hi Peter,

    In the example on top of this page, on the ‘Settings’ tab, an option ‘Search Settings’ is visible, which is not on my version (3.1.4) of the WP Data Access plugin.

    What I’m looking for is an example how to create an advanced search form with multiple fields. The user’s input could than be processed by a PHP-script on the server and a temporary results table could than be handled by the Data Publisher.

    However, I didn’t find out how to create search fields on a form with your plugin thus far.
    Would you be so kind to provide an example?

    Thanks in advance,
    Ike de Pagter

    1. Hi Iek,

      Sharp eyes! 🙂 I think I forgot to disable that option when I created that screenshot.

      The premium version of the plugin, coming out this month, allows to add a number of search option. The premium version is not free! If you are interested, here is a link to a video in which some of the premium search features are explained: https://www.youtube.com/watch?v=Zy_AWrULgCI

      Best regards,
      Peter

Leave a Reply

Your email address will not be published. Required fields are marked *