How do I display a view as if it's the front page via a module?
Posted
by Justin
on Stack Overflow
See other posts from Stack Overflow
or by Justin
Published on 2010-05-05T15:11:39Z
Indexed on
2010/05/06
22:48 UTC
Read the original article
Hit count: 276
I have a simple view that feeds a home page. I have a custom module that registers some specific URLs in hook_menu that I pass into my module so I can pass them as arguments into the view.
I can get the module to display the view all right, but it doesn't use the teaser/is_front view that outputs when I access the home page. I looked through the APIs but I can't seem to figure out how I can output the view via my module as if it's the front page, meaning $is_front is true and the teasers would appear.
The reason I'm not passing in the arguments via the URL bar into the view itself is:
- My argument list is known and finite
- The argument order is mixed, meaning I will sometimes have /argument1, /argument1/argument2 or just /argument2.
- I only want to capture the first level URL as an argument for specific, known strings (e.g. I don't want to pass /admin into my view but I do want to pass in /los-angeles, which I register in the menu system via hook_menu in my module)
Here are some examples to make this more clear:
- /admin - loads the admin page
- /user - loads the login page
- /boston - passes into the first argument of the view; shows in front/teaser mode
- / - shows view with no arguments
- /bread - passes into argument 2 of the view; shows in front/teaser mode
- /boston/bread - Passes into argument 1 and 2 of the view; shows in front/teaser mode
Maybe I'm going about this the wrong way? Or perhaps there is a way to have a module load a view and somehow set front/teaser mode?
Details: Drupal 6, PHP 5, MySQL 5, Views, CCK
© Stack Overflow or respective owner