Change Links in SQL Objects when Cloning Production to Test

Let me say at least one time in this article…..”Backup your Database before running the created text file.” Ok, now that I have said that let’s talk about a problem that occurs a lot, especially if you are working in multiple databases. If you have databases for Production and Test and you clone regularly then you know that sometimes you have to update stored procedures and views if they are linked to other production and test databases. Learn More

Tags: , , , , , , , , , , | Posted under Programming/Coding | Leave a comment

Get the Pagetitle of a Resource’s Parent in MODX

I’ve been doing too many long blog articles lately, so here’s a short one.

A MODX Forum user asked how to get the pagetitle of the current resource’s parent in Revolution. I thought I’d put my answer up here to make it easier to find.

It can be done with a very simple snippet that gets the parent field of the current resource, retrieves its parent object from the database, and gets the content of the parent’s pagetitle field.

This tag goes where you want the parent’s pagetitle to appear:

[code language=”html”]
[[!GetParentPagetitle]]
[/code]

Here’s the code of the GetParentPagetitle snippet. It’s a somewhat verbose version to make it easier to understand:

[code language=”php”]
$output = ”;

/* Get the current resource’s ‘parent’ field */
$parentId = $modx->resource->get(‘parent’);

/* Get the parent object */
$parentObj = $modx->getObject(‘modResource’, $parentId);

/* If we have the parent,
get and return the pagetitle */

if ($parentObj) {
$output = $parentObj->get(‘pagetitle’);
}

return $output;

[/code]

The if ($parentObj) sanity test is important. Resources at the root of the tree have no parent, so if this snippet executes in one of them you’ll get a PHP error when $parentObj->get() is called because the $parentObj will be null. Because we set $output to an empty string at the top of the snippet, that’s what will be returned if there’s no parent.

Here’s a much more compact version of the same snippet:

[code language=”php”]
$parentObj = $modx->getObject(‘modResource’, $modx->resource->get(‘parent’));
return $parentObj? $parentObj->get(‘pagetitle’) : ”;
[/code]

 


For more information on how to use MODX to create a web site, see my web site Bob’s Guides, or better yet, buy my book: MODX: The Official Guide.

Looking for quality MODX Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , | Posted under MODX, MODX | 2 Comments

Vanity Nameservers On Shared Linux Hosting

To set vanity nameservers on your shared Linux hosting account is a fairly easy evolution. Please keep in mind that you are not setting actual nameservers but masking Arvixe’s nameservers.

In your initial account information email look for a section titled Domain DNS Information. You should see an entry that looks like this: Learn More

Tags: , , , , , , , , , | Posted under cPanel/Linux Hosting, Domain Names | 1 Comment