-
Couldn't load subscription status.
- Fork 28
Content_tags
The content tags are the predecessor of the content functions which have been introduced in July 2021. Since then, content tags were considered deprecated in favor of the new content functions, and parsing/transforming support for the old syntax has been fully removed from the codebase in February 2024.
This means that users who are still using the old syntax in their entities' content are recommended to run the convert_content_tags.php script in the core/script directory to migrate to the new syntax.
This table contains all hardcoded content tags that existed.
| Tag | Description | Parameters |
|---|---|---|
BASE |
Return pure URL relative to root directory. | (string) path |
FILE |
Return pure URL relative to static directory. |
(string) path |
PAGE |
Return pure URL to a page entity. | (int) id |
POST |
Return pure URL to a post entity. | (int) id |
USER |
Return pure URL to a user entity. | (int) id |
Hello. Check out [my new post]({POST[123]})!<script>let userUrl = "{USER[1]}";</script>Result:
Hello. Check out [my new post](https://hostname/post/new-post/)!<script>let userUrl = "https://hostname/user/john_doe/";</script>The converter script can be found within the core/script directory. Just cd into the directory from the command-line and execute the script as follows (no worries, this is a dry-run first):
cd core/script
php convert_content_tags.php
You now can check the output in your terminal to verify if all matches would be replaced correctly. If you are sure that everything is good, execute the script with the commit parameter:
php convert_content_tags.php commit
The system currently has no mechanism to run scripts from inside the administration area. The script must be placed in a directory that is not accessible via web so no one can run the script in the core/script directory from HTTP context.
If you don't have terminal access, temporarily copy the script to your root directory and change the require statement in line 3 accordingly. You now can execute the script via web browser (the commit parameter can be passed as GET parameter).
The converter script loops through each entities' content and converts the old syntax to the new syntax in three steps, which are explained in detail below.
The script replaces all occurrences of the BASE|FILE syntax anywhere in the content, regardless of whether the tag is found within a Markdown formatted link or image syntax or somewhere else. All matches will be replaced with a call to the BASE_URL or FILE_URL content function.
Example:
<-- 
--> 
Because the new content functions CATEGORY|PAGE|POST|USER return a Markdown formatted link to the entity, the script searches for all occurrences of the PAGE|POST|USER content tags used as URL inside a (valid) Markdown formatted link.
It then converts the whole Markdown formatted link to just a call of either the PAGE, POST or USER content function with the original link text and title as parameters for the content function.
Example:
<-- Hello. Check out [my new post]({POST[123]})!
--> Hello. Check out {POST: 123, "my new post"}!
Now all PAGE|POST|USER content tags that are found anywhere else in the content will be replaced with the (PAGE|POST|USER)_URL content function, which will just return the absolute URL to the entity.
Example:
<-- <script>let userUrl = "{USER[1]}";</script>
--> <script>let userUrl = "{USER_URL: 1}";</script>