Showing posts with label modx. Show all posts
Showing posts with label modx. Show all posts

Thursday, April 16, 2015

solr query rows did not return all results

solr by default allows query
*:* and x=1

but it is not suppose to make sense if you are adding condition,
*:* should not be added.
but solr allows to return all results to match x=1.

but when use with edismax,
the results seems to return strange behaviour as it does not return all rows.
therefore, removing *:* does the tricks in use_dis_max = true is used.

Friday, November 9, 2012

modx setup blank page

After some research,
blank page could be caused by insufficient memory,
set php memory limit to higher

another possible issue is core/config/config.inc.php

it turn out , on my machine when i was migrating a remote modx to my local machine,
the write process onto config.inc.php somehow halted with some unknown error which caused blank page.
So, the page was a template file, and it turn out to be an invalid php script file.
ive to redownload my config.inc.php and try rerun..

But some how in the end, the final setup failed half way, with no errors again, content got loaded half way with no errors.

Yes, in the end, i applied the latest upgrade files onto the root,
and rerun setup,
but this time, it went well and it was a successful upgraded and the site is working!

Sunday, September 30, 2012

MODx Revolution IncludePage

The original includepage inspired by Daniel
This version is currently supported in MODx 2.2.4-pl
http://pastebin.com/sJcDJgC0


Reference:
http://www.dangibbs.co.uk/journal/modx-include-page-content-snippet

Monday, March 26, 2012

MODx Return Error 400 in manager

The recent changes on MODx seems to create a new kind of error 400 on all the javascript used in the manager screen.
The problem comes from issue with minified index.php where it over replaced manager/assets with assets path, therefore doubling the path to the actual javascript file.
The solution have been resolved in the nightly build of MODx 2.2.1.pl

http://tracker.modx.com/issues/7418

Thursday, March 1, 2012

modx package management could not install

After dabling around on my new server,
i realize that the package installer did not work.
Further examination reviewed the error "package could not be found".

So i went into the core/packages and found that the extraction process did not complete.
After searching around, 1 way to work around it is to set under setting,
search for "archive_with" and change it to true.

Make sure to delete the package with "force deletion" and redownload and try install again...
hope it works for you... :)

Sunday, January 29, 2012

modx page not found after upgrade to 2.1

There is some cache issue on modx, after an upgrade from modx 2.0.x
Clearing cache does not seems to fix the issue.
One way to fix it is to edit every resources which ever are effected...


Updates:
Another way is to do a script to run recursively on all resources, edit it by changing the alias, and save,
and then changing the alias back to the actual alias, and save it again.
Example:

function doFixResource($id, $iLevel=1) {


$oRes = $modx->getObject("modResource", $id);
$aContext = array($oRes->get("context_key"));
$iParentId = $oRes->get("parent");
if (!empty($iParentId)) {
doFixResource($iParentId, $iLevel+1);
}

echo "Fixing: " . $oRes->get("id") . "(lvl:" . $iLevel . ")," . $oRes->get("alias") . "::" . $oRes->get("pagetitle") . "(" . $oRes->get("context_key") . ")
\n";
$sAlias = $oRes->get("alias");
$oRes->set("alias", $sAlias . "-". rand(10000,9999));
$oRes->save(false);
//doFlushContext($aContext);
$oRes->set("alias", $sAlias);
$oRes->save(false);
doFlushContext($aContext);

}


then run flush script:

function doFlushContext($aContext) {
global $modx;

$modx->cacheManager->refresh(array(
'db' => array(),
'auto_publish' => array('contexts' => $aContext),
'context_settings' => array('contexts' => $aContext),
'resource' => array('contexts' => $aContext),
));

}

And finally, run clear cache from manager screen.

Tips: If you want performance, cached up all the id which you have run doFixResource by using static variable, and skip it, it may save you up to more than 80% of the time :)



Friday, January 27, 2012

modx 2.2 changes

$modx->getUser("contextname")
return anonymous user if no user is logged in to the context.
when getOne("Profile") is performed on anonymous user, will return null, so some error might be thrown.

modx->db->dbfunctions is now deprecated, so use the actual function from $modx itself.
for more information, refer here:
http://rtfm.modx.com/display/revolution20/Upgrading+MODx#UpgradingMODx-VersionSpecificChanges
http://rtfm.modx.com/display/revolution20/Summary+of+Legacy+Code+Removed+in+2.1

Example of a big change:

$modx->db->query is completely different from $modx->query

So you may use parseBinding to do your query.
Example:

$sSelectSQL = "select `parent`, `context_key` , id, `alias`, pagetitle, longtitle from modx_site_content where context_key=:contextand parent=:parent and `alias`=:alias and (published=0 or deleted=1)";

$aParam = array(":context" => "web",
":parent" => 1, ":alias" => "somealias");

$sResultSelectSQL = $modx->parseBindings($sSelectSQL, $aParam);
$stmt = $modx->query($sResultSelectSQL);

if (! $stmt) throw new Exception("SQL Failed: " . $sResultSQL);

//to fetch all
$aCount = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($aCount as $oRow) {
  echo $oRow["id"];
}
//to fetch one
$oRow = $stmt->fetch($PDO::FETCH_ASSOC);
echo $oRow["id"];


And other class based method:

//to get an object row
$oRes = $modx->getObject("modResource", array("context_key" => "web", "parent" => 1, "alias" => "somealias"));

echo $oRes->get("id");

modx 2.2 modX::isFrontEnd() is undefined?

After doing an upgrade to modx2.2, editing any resources seems to throw this error.
Solution, go to package manager, upgrade tinymce plugin.
And we are all set to go! :)

Saturday, December 31, 2011

MODx page not found on manager

This was a real trouble for me in the first place.
How am i suppose to fix this...
First, i did the throw exception as stated in my last post.

then next thing i know, i realize the $modx->config["modRequest.class"] wasn't declared...
so it uses modRequest instead of modManagerRequest class.

after digging for hours, ive finally noticed that the $modx->context->prepare() doesnt seems to return
proper config in $modx->context->config;

to fix it, add in true  into the parameter:
$modx->context->prepare(true);
then, load the manager page. you should be able to see the manager page now.
next, remove the true (restore the code to its previous state).
then login into the manager.
and Site > Clear cache.
Now all your site should have the proper config loaded based on the respective context.


MODx page not found...

Stumble upon modx page not found?
MODx by default, will send an error page if any error found during the loading of the page.
its in modx/core/model/modx.class.php

want to see the actual error?
go to the line declaration of
public function sendError($type = '', $options = array()) {
throw new Exception($errorMessage); //after $errorMessage is defined

Saturday, August 20, 2011

MODx Revolution and UTF8

If you ever need to insert in latin symbol or unicode into modx title or content...
Modify modx_site_content fields:
+ pagetitle, longtitle, description, introtext, content
to unicode_general_ci encoding.
(Note: This is a fulltext index, so you will have to execute 1 statement to alter all 5 fields)
And also modify template variable content:
ALTER TABLE  `modx_site_tmplvar_contentvalues` CHANGE  `value`  `value` TEXT CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL

Next, modify core/config/config.inc.php and change the line:
+ $database_connection_charset = 'utf8';
+ $database_dsn = 'mysql:host=...;dbname=...;charset=utf8';

And you may start testing it it works :)
In my setup, its somehow in njis charset... (im not sure why)

Tuesday, August 9, 2011

MODx Revolution Root resource alias / path?

I tried google around on this, and find it difficult to find the result.
I've found a solution to based my resource alias to the root of the site.
By going to system > settings
use_alias_path : no

This will change all your resource alias to be based from root.
Example:
Container1 > My page (resourcealias: mypage)
now become:
http://www.example.com/mypage

If you need the container path, just put the full folder path:
Example:
Resource alias: container1/mypage

Wednesday, May 25, 2011

MODx Revo TinyMCE font color, table button

Default MODx Revolution TinyMCE doesnt contain font colour or table button.
To add font color, go to system : system setting
search for filter: "tiny"
add "forecolor" into tiny.custom_buttons# key.
add "table" into tiny.custom_buttons# key.

then add "table" into tiny.custom_plugins

This shall do a quick fix to have the things you need.
But do look for tiny.css_selectors to do a proper font face and size via classes.

For other buttons and plugins:

Tuesday, April 26, 2011

MODx Revo unable to login to manager

If you try to login to manager screen, but unable to get any error message..
then you are likely to have key in the right password, but it auto redirect you back to manager login screen.

This is due to problem with current session.
Just clear the browser cache, and try reload the page and login again.
Hope this helps :)

Saturday, March 26, 2011

modx-combo cascading selection

After spending hours trying to figure this out,
and realized that modx have override most extjs combo with its own data store calling.

I've finally found a way to do cascading to work.
To force it to add the parameter to on call ajax to populate the list,
you will have to add it as baseParams, as the 1st time you select the drop down,
it seems to be doing a auto load.
If you attempt to reload the store without setting baseParams, the first time it got populate, it will be without your additional param.
Example:
Ext.getCmp("state").baseParams.key1 = Ext.getCmp("region").getValue();

But this baseParams only work for 1st time call. It wont work when you subsequencely reselect the parent component.
To do that, we will have to use the load.
Ext.getCmp("state").store.reload({
params: { key1: Ext.getCmp("region").getValue() }
});

This will solve the cascading selection issue.
For example of complete code:
----------------------------------------------------
lets say we have a region > state > district
Ext.getCmp("region").on("change", function() {
var oState = Ext.getCmp("state");
var oDistrict = Ext.getCmp("district");
oState.setDisabled(true);
oState.setValue('');
oState.store.removeAll();
oState.baseParams.key1 = Ext.getCmp("region").getValue();
oState.store.reload({
params: { key1: Ext.getCmp("region").getValue() }
});
oState.setDisabled(false);
oDistrict.setDisabled(true);
oDistrict.setValue('');
oDistrict.store.removeAll();
oDistrict.setDisabled(false);
});
Ext.getCmp("state").on("change", function() {
var oDistrict = Ext.getCmp("district");
oDistrict.setDisabled(true);
oDistrict.setValue('');
oDistrict.store.removeAll();
oDistrict.baseParams.key1 = Ext.getCmp("state").getValue();
oDistrict.store.reload({
params: { key1: Ext.getCmp("state").getValue() }
});
oDistrict.store.reload();
oDistrict.setDisabled(false);
});
-------------------------------------

Tuesday, March 8, 2011

Started a project: FlexiSiteCopy

A general purpose flexible utility to copy database from 1 site to another. Currently tested on MODx 2 and standalone database. Allow modification on data before inserting remote data to local database

Wednesday, January 26, 2011

MODx 2 Context setup

When setting up a site to a context, be sure to set these setting in the context:
  • site_url - site url to the domain
  • filemanager_path - the file manager path for this context to upload images / media
  • site_start - the starting resource id as home / landing page
  • site_name - the Site name to be displayed in email and page title

Sunday, January 16, 2011

MODx 2 Adding ... to intro text summary

If you plan to add "..." to a intro text or content which is more than some # of characters,
you may use if condition within the chunk.

Example below will add ... to intro text:
[[+introtext:if=`[[+introtext:len]]`:gt=`200`:then=`[[+introtext:limit=`200`]] ...`:else=`[[+introtext]]`]]

Monday, January 3, 2011

MODx loading other components lexicon

If you need some lexicon from another components from your snippet,
you may do so by running this in snippet:
$modx->lexicon->load("namespacename:filename");

Example:
$modx->lexicon->load("login:register");
//resolve to: core/components/login/lexicon/register.inc.php

Thursday, December 23, 2010

MODx 2.0.6 update

MODx team have finally made it right :)
Every logged in session now have to be in
$_SESSION["modx.user.contextTokens"]

Example:
$_SESSION["modx.user.contextTokens"]["web"]=UserId#


And $modx->executeProcessor($options) now get $scriptProperties from $options, no longer $_POST.