Internal Links using PageID
Hi Admin,
Sometimes, I reorganized wiki pages (moving to another sub-page, rename wiki) and it will break the links from another pages.
Can we use wiki PageId to create links because PageId never be changed.
Thanks and Regards,
Show Files (1 file)
Comments
Log in or create an account to post a comment.
Re: Internal Links using PageID
I created this simple action code
<?php // {{link pageid=}} if (!defined('IN_WACKO')) { exit; } if (!isset($pageid)) $pageid = ''; if (!isset($inline)) $inline = '0'; $pages = $this->db->load_all( "SELECT tag, title " . "FROM " . $this->db->table_prefix . "page " . "WHERE page_id IN ( " . $pageid . ")" . "ORDER BY title"); if ($inline == '0') { echo '<style type="text/css" scoped>ul + br {display: none;} ul,ol {margin-top: 10px;margin-bottom: 10px;}</style>'; echo '<ul>'; foreach ($pages as $_page) { echo '<li>' . $this->link('/' . $_page['tag'], '', $_page['title']) . '</li>'; } echo '</ul>'; } else { echo $this->link('/' . $pages[0]['tag'], '', $pages[0]['title']); }and then call it in wikipage
{{link pageid=313}}Re: Internal Links using PageID
Improved action with template:
action/plink.php
action/template/plink.tpl
[ === main === ] [ ' message ' ] [= u _ = [ ' // move to CSS file and asign class ' ] <style scoped> ul + br {display: none;} ul, ol {margin-top: 10px; margin-bottom: 10px;} </style> <ul> [= l _ = <li>[ ' link ' ]</li> =] </ul> =] [= i _ = [= l _ = [ ' delim ' ][ ' link ' ] =] =]To the topic itself more later, I just improved your action. I renamed the action to plink to distinguage it from similar actions/functions.
Re: Internal Links using PageID
Hi Admin,
I got error
Re: Internal Links using PageID
Please check for a copy or file naming error.
I tested it on my local XAMPP, and copied it. Main is declared, you may compare it with a similar template - right now I can't spot an error.
Re: Internal Links using PageID
Which version did you use for test?
I am using Wackowiki version: 6.0.25
Re: Internal Links using PageID
There is no difference between the versions regarding the template engine. Looks like a typo or copy error to me. I can provide a zip file tomorrow.
file:plink_action.zip
Please try the sample files in the zip file. The problem with copy code around is, that the template requirers the correct line feed to work.
Re: Internal Links using PageID
Hi Admin,
I have uploaded the files. there's no error but the page didn't show anything.
Re: Internal Links using PageID
Please check the SQL query log, it should show you the error. Whith
truethe query gets cached. I have a 6.0 testing instance, but didn't used it - what could go wrong.An empty result indicates, that it throw the return, so it has no results. You can add there also a message.
Re: Internal Links using PageID
Got it,
I changed this line
if ($pages = $this->db->load_all( "SELECT tag, title " . // "FROM " . $this->prefix . "page " . // <<-------change this line "WHERE page_id IN (" . $this->ids_string($_page_ids) . ") " . "ORDER BY title", true) )to
Thanks WikiAdmin..
Re: Internal Links using PageID
Good to know that it works, the table prefix is already available in the 6.0 repo head, but I did not check against the 6.0.32 tag. The non-working template was probably caused by a non-complient line feed. I forgot to mention that LF line ending is mandatory.
If you don't do this in templates, the templating engine will throw an error:
templatest: no main template found in action_or_handler/template/path.tpl