Loading...
 
Skip to main content

Features / Usability


Apply template without removing contents?

When editing a wiki page, if a template is applied, existing contents will be deleted. Is there a way to change it so a new template could be appended without overwriting exsisting contents? This could be helpful in these cases: 1) A user didn't apply a template when creating the page, but later on (or sb else) can easily apply the template to it. 2)Apply multiple templates to a single page.

Is it relatively easy to hack? Thanks.

OK, I have a raw hack that kinda works. In tiki_editpage.php chage:
1. Line 517: (remove the 'preview' check)
CHAGE:
if %22templateId%22) && $_REQUEST%22templateId%22 > 0 && !isset($_REQUEST'preview' && !isset($_REQUEST['sa" class="wiki wikinew text-danger tips isset">$_REQUEST%22templateId%22) && $_REQUEST%22templateId%22 > 0 && !isset($_REQUEST'preview' && !isset($_REQUEST'save'
TO
if %22templateId%22) && $_REQUEST%22templateId%22 > 0 && !isset($_REQUEST'save'" class="wiki wikinew text-danger tips isset">$_REQUEST%22templateId%22) && $_REQUEST%22templateId%22 > 0 && !isset($_REQUEST'save'

2. Line 519: (append previous edits)
CHAGE:
$_REQUEST%22edit%22 = $template_data%22content%22;
TO:
$_REQUEST%22edit%22 = $_REQUEST%22edit%22 . "\n" . $template_data%22content%22;

It allows template text appended to the end, and you can apply templates multiple times. I just start learning PHP and not familiar with Tiki at all, so I guess it's not a smart hack and might break something else. But it seems to be working on my test site.

Cheers.


Urgh, forgot to put CODE tag in...but why I can't edit/remove my previous reply? Here it is again:

OK, I have a raw hack that kinda works. In tiki_editpage.php chage:Image
Copy to clipboard
1. Line 517: (remove the 'preview' check) CHAGE: if (isset($_REQUEST["templateId"]) && $_REQUEST["templateId"] > 0 && !isset($_REQUEST['preview'] && !isset($_REQUEST['save'])) TO if (isset($_REQUEST["templateId"]) && $_REQUEST["templateId"] > 0 && !isset($_REQUEST['save'])) 2. Line 519: (append previous edits) CHAGE: $_REQUEST["edit"] = $template_data["content"]; TO: $_REQUEST["edit"] = $_REQUEST["edit"] . "\n" . $template_data["content"];

It allows template text appended to the end, and you can apply templates multiple times. I just start learning PHP and not familiar with Tiki at all, so I guess it's not a smart hack and might break something else. But it seems to be working on my test site.

Cheers.