Several clients have needed a simple way to "hide" pages on their website so they are only viewable to visitors who have been provided with the page URL. I do this by creating a special page template with a "noindex" metatag, and then advise them when creating the page to:
- uncheck "Show in menu"
- replace the default page alias with a random string of letters (so the URL is more difficult for a non-authorised visitor to guess)
BTW, I realise this doesn't provide a great deal of security - it's just for basic privacy.
This is all fine, but I thought I'd see if there is a way to automate this process. I was thinking of attaching a UDT to an appropriate event, which did something like...
if page parent = x then uncheck "Show in Menu" and replace page alias with randomised string
But I can't see an event that fires only when a page is first created. There's ContentEditPre/Post, but I don't want the alias randomised on every edit. Is there a suitable event I can attach to, or any other suggestions on achieving this?
Thanks.
[solved] Randomise page alias when page first created
[solved] Randomise page alias when page first created
Last edited by Cerulean on Sat Apr 26, 2014 7:13 am, edited 1 time in total.
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
Re: Randomise page alias when page first created
No, there is no event or any other mechanism to grammatically change the page alias algorithm. sorry.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Re: Randomise page alias when page first created
Install front end users module, set it to allow multi log in of user, make one user and give this out to every one to log in, set the pages to Content Type: Protected...
Re: [solved] Randomise page alias when page first created
Ummm... what happened to the rest of the replies that were in this thread? Moved? Deleted? Why?
Re: [solved] Randomise page alias when page first created
Looks like the disappeared replies will remain a mystery.
Anyway, here is the final UDT attached to the ContentEditPre event:
Anyway, here is the final UDT attached to the ContentEditPre event:
Code: Select all
$content_obj =& $params["content"];
$parentid = $content_obj->ParentId();
$extra = $content_obj->GetPropertyValue("extra1");
// Adjust parentid below as needed
if ($parentid == 33 && $extra != "is-randomised") {
$random = substr(md5(time()), 0, 12);
$content_obj->SetAlias($random);
$content_obj->SetShowInMenu(false);
$content_obj->SetPropertyValue("extra1", "is-randomised");
}