Good morning everyone!
I am rather new to ModX, so this may be stupid but help me, please. I installed "Login" snippet and now I want to redirect all users that are not logged in from any page to one page (id :1), and redirect all users that are logged in from that page(id :1) to another (id :2). I thought that the most simple solution is to write a quick plug-in and set it "OnWebPageInit".
$logged_out_doc_id=1;
$logged_in_redirect_doc_id=2;
if(!$modx->userLoggedIn()) {
$modx->sendForward($logged_out_doc_id);
}
elseif($modx->documentIdentifier==$logged_out_doc_id) {
$modx->sendForward($logged_in_redirect_doc_id);
}
But documentIdentifier (and the whole documentObject) seem to be NULL there. On what moment that objects are created? I looked up all available variables and now I use $modx->resourceIdentifier, but that doesn’t feel right.
Two more minor questions:
1) When i create snippet/plug-in there is "<?php" already in it (and no "?>"). Why?
2) This is complex and I don’t know what details should I post here, but ModX seem to take loads of CPU on my local computer (not on my other server). I used standard apache2 + php5 + mysql on Ubuntu with a few additional modules for php (xdebug etc.). FreeBSD server works great. When i am in ModX manager on my local computer each ajax request eats about 30% or more of cpu and last from 1 to 5 sec. Web pages take about 300ms. All my other projects work great on the same computer.
Thank you all in advance! (And sorry for my bad english)
Edit:
ModX: MODx Revolution 2.0.3-pl
mysqld: Ver 5.1.41-3ubuntu12.6 for debian-linux-gnu on i486 ((Ubuntu))
apache2: Apache/2.2.14 (Ubuntu)
php: mod_php on apache2, Version 5.3.2-1ubuntu4.5
OS: Ubuntu 10.04 with latest updates
kernel: 2.6.32-25-generic
Everything is standard for Ubuntu, nothing custom build here.