Jul 05, 2009, 01:39 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Search via SMF or Google: modx forums all of modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
News:Donate to MODx: Donations
Pages: [1] 2 3 ... 9   Go Down
  Print  
Author Topic: [Hack] Subsites - (Solve Friendly Alias Path)  (Read 37451 times)
0 Members and 1 Guest are viewing this topic.
Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« on: Jan 05, 2006, 12:27 PM »

EDITED

Hi guys, I make this as an official hack from me to MODx. Waiting for the core team to decide whether it's going to be implemented for the future release or not.

This hack will allow multiple domains to be hosted on one MODx installation base. Manager able to setup the desired strart doc id and error doc id for each subsites under System Settings configuration page. This mostly affect friendly alias path that is being turned on.

Now it provides root folder for the subsites to be located anywhere, without the needs to located them right on the first level or root level. The alias itself can be anything as well, doesn't have to be the domain/subdomain name.

It has been tested for several minutes by me. If somebody willing to test this further, it will be great.
PS: Modification doesn't affect any usability of using other resources created for MODx, due to the fact this hack changes all the needed API to keep everything act as if there is no modification at all.

Here is a little scrrenshot for the system setting page

* Subsites v1.0.zip (54.74 KB - downloaded 699 times.)

* subsites.gif (3.84 KB, 590x185 - viewed 3690 times.)
« Last Edit: Feb 28, 2006, 12:13 AM by Djamoer » Logged

Mark
Coding Team
*
Posts: 3,250


Ditto Developer


WWW
« Reply #1 on: Jan 05, 2006, 12:56 PM »

The actual MODx parser is in /manager/includes/document.parser.class.inc.php.

Hope that helps!
Logged

xwisdom
Foundation
*
Posts: 1,732



« Reply #2 on: Jan 05, 2006, 01:01 PM »

Maybe you need something like an OnMakeUrl event so you can modify all your MODx generated urls from a plugin without having to hack the core, correct?
Logged

xWisdom
www.xwisdomhtml.com
The fear of the Lord is the beginning of wisdom:
MODx Co-Founder - Create and do more with less.
Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #3 on: Jan 05, 2006, 01:12 PM »

Yeap, actually I still need to hack the core though, I change the makeFriendlyURL() and makeURL() function to make sure that every friendly alias path need to be outputed, it will remove all the leading alias virtual directory, which based on the name of the domain being used.

For example, "subdomain.domain.com/home.html". The "subdomain.domain.com" is the first folder level that is going to contain all the documents specific to that subdomain. So in this case, both of the methods, instead of outputing that, it will remove the "subdomain.domain.com", and return "home.html".

Now the last bit that I need to change is executeParser() function, which is before the event onWebPageInit, I hack into the function and change $alias variable to be appended with "subdomain.domain.com", before the $alias variable being processed and returning the exact document.

All the changes will only happen, when the alias path option being enabled in the manager setting. I also plan to have a new configuration setting, to enabled this mode, which allow subsite or not, if it is, then all the changes in that 3 functions will run, if not, it will proceed as standard MODx system.

Do you think this is do able? Did I cover all the basic ground for subsite? I did the changes of the executeParser() function and it works.

Please let me know if I do wrong, and I really appreciate all the helps, because I'm not a good PHP programmer, so any help from the core coder will be awesome.

Thanks
Logged

xwisdom
Foundation
*
Posts: 1,732



« Reply #4 on: Jan 05, 2006, 02:15 PM »

I think it's workable but you just have to give it a try.
Logged

xWisdom
www.xwisdomhtml.com
The fear of the Lord is the beginning of wisdom:
MODx Co-Founder - Create and do more with less.
Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #5 on: Jan 05, 2006, 02:36 PM »

My last question, hopefully.

Is there anyway to search document id based on their alias, other than going back and forth of the database? Is there any function available to do that? I haven't check the API function yet, but if somebody could direct me, it will be great.

How do I add a new option under manager setting inside the core code to have subsite disable or enable option?

Jason, if you can give me a hint, it will be really2 awesome.

Thanks
Logged

Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #6 on: Jan 05, 2006, 02:40 PM »

I found this wonderfull array inside the core
Code:
$modx->documentListing

Can we use that for snippet as well? It has all the pages alias with the corresponsding pageid attached to it.

It's awesome.
Logged

Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #7 on: Jan 05, 2006, 03:48 PM »

Thanks jason for the help, I have the subsites working just fine now, without having to use .htaccess.

I did a lot of hacking inside the document.parser.inc.php, but it's mostly just adding a few lines of code to modify certain behaviour in producing friendly alias path, while on subsites mode. It also change the site start and error page to the parent folder for subsites.

All I need is to modfy the manager setting to have this option available for user to check or uncheck.

Btw, is there any thought of implementing madmage multi lingual solution? I think it will be a good start for modx to have multi lingual solution.

PS: Sorry if this post containing a bunch of topics, which are unrelated to the topic itself. Don't ban me for this moderator.  Tongue

Regards,
Logged

rthrash
Foundation
*
Posts: 10,471



WWW
« Reply #8 on: Jan 05, 2006, 04:00 PM »

Wendy, we'll be seriously evaluating when and what method for front-end multi-lingual sites very soon. Smiley
Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #9 on: Jan 05, 2006, 04:25 PM »

Wendy, we'll be seriously evaluating when and what method for front-end multi-lingual sites very soon. Smiley

That's a good thing to know. Please update me when the time come. I'm looking forward for the future of MODx, by looking at the current progress right now, I can see the multi lingual content being implemented in the near future.

Btw, I'm done with subsites hacking, I added 2 options in manager system configuration setting to allow subsites or not, and it's going to depend on their domain. I believe this subsites solution is only affecting user who want to use alias path.

If it is going to be implemented to the core, I wouldn't mind sharing what I did with the code.
Hoping this could be on official option on MODx in the next release, including the multi lingual from madmage or whatever that you guys come up with.

Thanks for nurturing this system.
Logged

rthrash
Foundation
*
Posts: 10,471



WWW
« Reply #10 on: Jan 05, 2006, 10:58 PM »

Wendy, please PM with details where some of the core team folks can take a peek under the hood, so to speak. Thanks!
Logged

MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #11 on: Jan 06, 2006, 09:52 AM »

sure thing ryan, I'll do that either tonight or tomorow, kinda in the middle of project right now, but as soon as I have free time, I will setup a testing account. Hemmm... I think I might need one too for developing my modules and etc. It's better to have it in seperate installation, don't you think, rather than in production website?

Anyway, looking forward to be updated with the decision of multi lingual and sub sites, plus quick edit ability to create a new document.   Grin
Logged

Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #12 on: Jan 08, 2006, 01:16 PM »

Hi guys, here is the testing site to try on

http://test.djamoer.net/
http://test1.djamoer.net/

Notice the link for dropdownmenu on the right site. You can see that it will automatically truncate the front alias, when you're on test1.djamoer.net. It will aso set the starting page and error page to the document that has that alias the same with the domain being used.

Anyway, feel free to look around, you can enabled or disabled this on manager site setting, which have 2 addition for enabling/disabling, as well as determine the main domain for the site.

Known issue, the hack can't differentiate between www.test1.djamoer.net and test1.djamoer.net. It can be fixed with a few addition to the code, but I'm just way too lazy, so I use mod rewrite to make sure that all the incoming www.test1.djamoer.net will directed to test1.djamoer.net
Logged

Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #13 on: Jan 19, 2006, 05:21 PM »

Just wanna bring this thing up again.

I attached the files that I modified on the core code.

You can find all the code that I added being commented with "subsites", so you guys can search with subsites as the keyword to find the code that I added.

I think it works just fine so far for me. Never encounter any problem in integrating other snippet without having to hack the snippet again.

Regards,

* Subsites Hack.zip (53.39 KB - downloaded 666 times.)
Logged

Djamoer
Emeritus
******
Posts: 1,495

No one can limit a man other than the man himself.


WWW
« Reply #14 on: Feb 28, 2006, 12:12 AM »

Official hack from me. Hope you guys find it useful.

Please report back to me, if there is any bugs or problems.

Sincerely,
Logged

Pages: [1] 2 3 ... 9   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF | SMF © 2006-2008, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!