This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

MVC for Drupal Modules

Hi,

I'm using Drupal for a couple of month now and since I want to use it for all my further projects I'd really like to be able to write my modules using some basic MVC architecture.

So here is how I want to do it: I want to have a module called 'mvc' which will include my basic classes for Model's, Controller's and Views and I want to have a new Folder in modules called mvc with the following sub-folders:

mvc/models
mvc/controllers
mvc/views

Whenever a page is requested and no page is found I want to make drupal call a function of my mvc modules which is going to look for a controller with the name of the first argument. So for example if somebody calls www.my-site.com/projects/add and drupal doesn't have a path for that registered I want my mvc module to check if there is a file called mvc/controllers/projects.php and if yes include that file (+ models, views) and check if there is a class called mvc_projects and if yes initalize it and call a function in it passing the other arguments (here: 'add'). Then the controller will use a switch statement to figure out the kind of request and after that calling various functions on the model and finally call a function in the view class in order to display the entire thing.

So my question basically is:
- How do I tell drupal to make a function of my module the default 'page not found' callback?

For everybody interested in the mvc the module itself here is what I want to accomplish:

Getting URL to render properly in filter module...

I'm writing a filter module which allows a limited range of simple Textile-type markup, with *bold* and _underline_ and the like.

Most everything works fairly well, but I'm have a problem with URLs. With ALL OTHER FILTERS SHUT OFF, if I specify a URL in the markup, like so:

[www.somesite.com| the site]

it creates a link, but the URL of the link turns out to be

http://www.MYSITE.com/www.somesite.com

destination attribute in URL

Greeting,

I have the following code in my module and 'destination' attribute is completely ignored after user logs in.

if (!($user->uid > 0)) {
  drupal_set_message(t('Login or <a href="/%reg-link">register</a> to continue the purchase process', array('%reg-link' => url('user/register'))));
  drupal_goto('user?destination=' . $goBackURL);
}

Any clues?

Thanks.

Ordering of functions in module?

What order should functions be in in a module? Or does it not matter? I couldn't find anything in the handbook (sorry [very sorry] if I missed it there, and this is a needless post).

Filemanager (attachment + acidfree problem)

Hi.

I'm completely stunned after trying to get the filemanager module working with acidfree (also tested with attachment module, with the same result).

I did this:
1. Installed filemanager, acidfree and attachment modules (setup database for every module).
2. Entered the correct settings for all the different modules.

When I try to upload a image (acidfree) I get the following error:

File copy failed: no directory configured, or it could not be accessed.
File copy failed: no directory configured, or it could not be accessed.
File copy failed: no directory configured, or it could not be accessed.
(yes, 3x times. only one time if using attachment module)

I figured that it had to be my paths in admin/settings/filemanager but all the paths are correct and the folders have the correct attributes (apache writable). Acidfree have actually created the working/0/ folder, but it cannot upload / save the actual images. I have tried both relative and absolute paths and have made sure that the public url is correct and working.

When I try to upload a image everything works, except that the image is not saved to disk. The image node is saved and working. Just the image missing.

The drupal log shows nothing except:
2005-11-18 22:35 acidfree: added Test

No error messages in the log.

I am using latest version of drupal (6.4.3) and the latest version of all the three modules.

Is there a way to randomly display different sidebar blocks to give a more dynamic feel?

Hi all,

I was wondering if there happens to be a way to allow for either random or rotation of a block displayed in the sidebar. Specifically, i would like to rotate through different "link ads" on the right sidebar to give the site a more dynamic feel.

Any suggestions would be appreciated (and I appologize if i have missed this topic in the forum)

Thanks!

Sam Gilman

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions