Closed abdolnabi closed 1 month ago
Thanks for your contribution. As I understand it, what you are looking for is an option which allows a shortcode to be added which is replaced only by the URL to open the tool, and omits any surrounding HTML to create a hyperlink within the WordPress page. If that is correct, then I would not consider this to be a target option which is part of the LTI spec. It seems to me that you merely need an attribute which renders the shortcode as a simple URL. For example, do you think something like the following would solve your issue?
[lti-platform tool=saltire id=iofkljfg urlonly]
which would be replaced with a URL like:
https://my.wordpress.site/?lti-platform&post=[x]&id=[id]
where [x]
is the ID of the post containing the shortcode and [id]
is the ID of the shortcode link. This link would generate an launch message to the LTI tool (with the setting for the presentation_document_target being included in the message). This assumes that the location where the LTI tool is opened is actually controlled by the HTML code in which the shortcode is embedded, rather than this plugin, so it is possible that the parameter included in the LTI message may not accurately reflect the actual location of the tool. It would rely on the tool or shortcode being consistently configured.
Thanks for the explanation, my requirement is to find a url of the lti course’s (my lti tools) which is working on any page from anywhere, just imagine this scenario, I have some blog posts with this course’s shortcode in custom parameters, and I need to display blog posts on the blog page with the link to the course as a button below each blog post fetching their link from the shortcode stored as a custom parameter, when it is fetching the shortcode the page id and shortcode id is not aligned to the blog page and only works on that specific blog post. Now I’m trying to find a way to make the course urls working on everywhere not only on the main blog post the shortcode defined on it.
Also I tried the shortcode the way you mentioned above like [lti-platform tool=saltire id=iofkljfg urlonly]
but it will replace the shortcode with an href tag like below:
`<a href="https://my.wordpress.site?lti-platform&post=[x]&id=[id]" title="Launch [tool_name] tool" target="_blank">[tool_name]</a>`
Sorry if I was not clear. My previous response was merely trying to outline a proposed solution to meet your needs; it was not intended to describe an existing solution. Do you think my proposal is suitable?
Some questions about your response:
my requirement is to find a url of the lti course’s (my lti tools)
What do you mean by an LTI course? Does this relate to a page within an LTI tool?
which is working on any page from anywhere
What types of page are you referring to here? More than just those stored in the WordPress posts
table?
this course’s shortcode in custom parameters
Are you referring to LTI custom parameters, or a WordPress element?
Thanks very much for your clarifications and detailed questions, please find my responses below: 1. My requirement is to find a URL of the LTI course’s (my LTI tools)
Response: An LTI course in this context refers to a specific educational resource or set of activities from OpenLearning, which is integrated into our WordPress site using the LTI 1.3 standard. The URL of the LTI course is essentially the target URL provided by OpenLearning that allows for LTI-based connections. This URL is used to launch the LTI tool from WordPress and typically contains the endpoint that handles LTI launch requests within the OpenLearning platform.
2. What do you mean by an LTI course? Does this relate to a page within an LTI tool?
Response: Yes, by an LTI course, I am referring to an OpenLearning course that is integrated into our WordPress site via an LTI tool. It does not directly relate to a traditional web page but to a course hosted on OpenLearning, which is made accessible within our WordPress environment through LTI integration. The courses are represented as external content embedded or linked from our WordPress posts, enabling direct interaction with OpenLearning’s LTI-compliant content.
3. Which is working on any page from anywhere. What types of page are you referring to here? More than just those stored in the WordPress posts table?
Response: The phrase “working on any page from anywhere” refers to the flexibility of placing LTI tool links or buttons on various parts of our WordPress site, not limited to the individual course posts. While each course has its own dedicated post, we also have a centralized course list page that aggregates these courses. The LTI links or start course buttons can be included on this list page, other posts, pages, or even widgets throughout the site, facilitating access to the LTI courses from various navigational points within the WordPress environment.
4. This course’s shortcode in custom parameters. Are you referring to LTI custom parameters, or a WordPress element?
Response: In this context, the reference to “shortcode in custom parameters” pertains to a WordPress element — specifically, a shortcode that we use to embed or link to the LTI course. This shortcode is designed to utilize custom parameters that are stored within each course’s WordPress post as metadata. These parameters might include identifiers, keys, or other course-specific data that configure the LTI link to launch the corresponding course in OpenLearning. The shortcode facilitates the dynamic generation of these links based on the metadata stored in each course’s post, ensuring that the correct course is launched via the LTI integration.
Thanks for the further details. Some follow-up questions:
posts
table. For example, is your "centralized course list page" a bespoke PHP/HTML page? (I have no experience of support for shortcodes outside a WordPrress page/post.)Here's your response formatted in Markdown:
Apologies for the delayed response, and thank you for your patience. I’ve reviewed our setup and would like to clarify the following points regarding the implementation of the LTI launch and shortcode integration:
Page Storage:
LTI Launch Metadata:
Passing Course-Specific Values:
class_id
attribute to OpenLearning as part of the custom parameters in the LTI tool. This method aligns with our need to specify certain course details directly within the launch parameters.Design and Usability:
I hope this clarifies our approach and the requirements. I look forward to your guidance on how we can best implement these functionalities within the current framework of the plugin.
Thank you for your support.
Thanks for the clarifications. It sounds like there is no need to include metadata from the WordPress page in the LTI message, so your original request of merely being able to render the shortcode as just the URL needed to launch the LTI tool so that it can be included in bespoke HTML is sufficient for your needs. So my original proposal to add an attribute to the shortcode of something like urlonly
would support this requirement.
To address your issue, my proposal is to add a new optional attribute to the shortcode named "output". The attribute can have a value of "url", "title", "width" or "height". When present the shortcode will be replaced with just the value of the specified item with no additional HTML. Any double quotes will be replaced with """ to allow the value to be included within an HTML tag. Does that sound like it will address your needs?
I’m not sure if I get it correctly, can you give an example of the shortcode output with those attributes you’ve mentioned earlier?
Sure. Updating my example from above, the shortcode would be:
[lti-platform tool=saltire id=iofkljfg output=url][/lti-platform]
which would render as:
https://my.wordpress.site/?lti-platform&post=[x]&id=[id]
where [x] is the ID of the post containing the shortcode and [id] is the ID of the shortcode link.
A shortcode of:
[lti-platform tool=saltire output=title][/lti-platform]
would render as:
Launch saltire tool
Note that the id
attribute is not required when the output
attribute is not set to url
. The following shortcode would render a title of "Launch LTI tool" but is rather redundant as it could just be replaced with the value itself:
[lti-platform tool=saltire title="Launch LTI tool" output=title][/lti-platform]
A shortcode of:
[lti-platform tool=saltire output=width][/lti-platform]
would render as:
750
assuming this is the width specified in the tool's configuration.
NB previous comment has been edited to add closing shortcode tags.
Given our ongoing discussion, the solution seems viable. However, I'm curious about a couple of scenarios concerning the WordPress page context, particularly for a specific post type like 'portfolios' which uses the posts table but doesn't support Gutenberg—only the classic editor is available.
Shortcode Implementation for Classic Editor: How should the shortcode be structured for a specific LTI tool if we are limited to using the classic editor on these 'portfolio' post types? Is there a particular approach or modification required in the shortcode function to accommodate this editor?
Shortcode Behavior on Aggregate Pages: Additionally, if I have a WordPress page that displays a list of portfolio posts, each embedded with its own LTI tool shortcode, will these shortcodes function independently when viewed on the aggregate list page? Essentially, if this page contains multiple LTI tool shortcodes from different portfolio posts, is there any conflict or issue in rendering each shortcode correctly in such a setup?
These questions aim to ensure clarity on how the shortcodes interact with different editors and across various display contexts. Looking forward to your insights on this.
I have not tried adding the LTI Platform shortcodes to portfolio pages, but since they can be typed manually (as in my examples above), I see no reason why they should not work, assuming that WordPress parses these pages for shortcodes when displaying them. Each shortcode to launch a tool must have a unique value for its id
attribute, so displaying multiple links from multiple pages should work. Perhaps you can try it out with the existing shortcode functionality to add LTI tool launch links and see if it does?
That's a fantastic discovery! Utilizing custom parameters within the shortcode to pass the page_id
and differentiate LTI tools for specific courses sounds like an effective solution. Here’s how I implemented it based on your insight:
[lti-platform tool="xxx" id="xxyzxx" custom="page_id=xxyyzz; class_id=6668...367845"]
This approach enables the use of a single LTI tool across multiple courses by specifying unique class_ids
for each, ensuring the correct course context is maintained when navigating from the general course link to the specific course page on the LTI platform.
It seems we might be encountering a specific challenge with how the shortcode interacts with custom fields. When the shortcode is embedded in a custom field of WordPress posts rather than directly in the post content, it appears that the shortcode does not function properly when called from a list on another page, resulting in the "No LTI tools found." message.
Two comments on your last two messafes:
id
value should not need to be repeated as a custom parameter as it is used as the LTI resource_link_id
parameter which is one of the few required parameters in an LTI launch message.Just to make sure I am understanding your requirements correctly:
Does this sound correct? If so, are you able to provide an example of the value(s) which might be entered in a page's custom field(s) and the HTML which your script might render from it/them?
That sounds correct. For the third point, I won't be writing a script as I'm utilizing the Cornerstone WordPress page builder, which can extract custom fields from the posts/pages. Using the theme and page builder's capabilities, I've set up the custom field like this:
[lti-platform tool=i2d33d5c6d7d id=da3602335 target=urlonly]
This is then rendered on the page as a button link for one of the courses. When users click on "see details", they see the following:
Thanks for the response. It sounds like my proposal will work for you, just changing the shortcode from your sample to:
[lti-platform tool=i2d33d5c6d7d id=da3602335 output=url]
Does your code currently work without adding a closing [/lti-platform]
tag? I suspect it might as this is the only contents of the custom field.
So my only remaining concern is how to prevent more than one link being added to a page with the same resource link ID parameter (id attribute), which is a requirement of the LTI spec. Is there anything within the Cornerstone WordPress page builder which would prevent the contents of the custom field from being used more than once?
One further issue to be considered. The shortcode is currently replaced with a link to a URL of the following form:
where [x]
is the ID of the post containing the shortcode and [id]
is the ID of the shortcode link. The post ID is needed so that the shortcode can be located when a launch is processed (so its attribute values can be accessed). If your use case is assembling elements from different posts (pages) onto a single page, the question in my mind is which post ID is passed to the shortcode method when it is being rendered. Is it the post ID where the shortcode is specified (which is what is needed) or is it the ID of the post on which the post is being included? If you can inspect the URL generated on a sample page then you should be able to tell from the post parameter included in the launch URL generated by this plugin. If it is for the page being displayed then the issue will be how can the ID of the post from which the shortcode comes be found by the plugin.
Sorry for the late response — I've been quite swamped over the last couple of weeks and just realised I hadn’t yet replied to your latest question. Regarding your query about the shortcode's behaviour, the post ID that gets passed is indeed the one containing the shortcode, not the ID of the page where the posts are displayed. Let me know if there's anything else you need clarity on!
Excellent, thanks for confirming this, it should make life easier. All I now need to do is add code to look for shortcodes in a post's custom fields.
On reflection, I am also planning to change the output=url
attribute to output=href
to avoid possible confusion with the LTI message URL.
I believe the latest commits to this repo add support for your use case. Are you able to check it out before I make a formal release? Use a shortcode like the following:
[lti-platform tool=saltire id=iofkljfg output=href][/lti-platform]
Note that the support for checking custom fields for shortcodes must be enabled on the plugin's default settings page.
Sorry for the late reply; I was pretty busy last week. I checked out your latest commit, and it was working as expected. Thanks very much.
Excellent, thanks for confirming this. I will make a new release for these changes soon.
Issue Description:
In the Celtic project under the
wordpress-lti-platform
, the current shortcode implementation for displaying LTI tool links and titles ([lti-platform tool=saltire id=iofkljfg target='']
) only supports a limited set of target options: "New window", "popup", "iframe", and "embed". There is a common need, especially when integrating with custom elements, to use only the URL of the LTI tools without embedding or opening them in new windows.Feature Request:
It would be highly beneficial to add an "URL only" output option to the shortcode. This feature would allow developers to retrieve just the URL of an LTI tool, enabling more flexible integration possibilities, such as linking directly from custom buttons or other UI elements without altering the behavior dictated by the
target
attribute.Potential Benefits:
Example Use Case:
A developer wants to create a custom button on their site that links directly to an LTI tool without opening it within an iframe or a new window. Specifically, using a WordPress page builder, the developer plans to incorporate custom elements or buttons that require direct URLs to LTI tools for seamless integration. Currently, this is not possible with the existing shortcode options which limit output to embedding methods like iframe or popup windows. The addition of a "URL only" option would enable more streamlined and custom integrations within WordPress environments.