OK, I've been tinkering with Drupal for a while now and have spent a lot of time digging around in the handbooks, forums and API docs, but still find myself confused as to how to achieve the end result I want. So, I hope if I describe what I want in broad terms someone can tell me how to go about achieving it. FWIW I think some sort of overview of how Drupal works is sorely needed, including info on where/how one can modify things. As it is I still have no idea whether I need to hack existing code, write a module or do theme stuff.
The site structure uses a taxonomy vocabulary with both page and story nodes. All very standard. I would like each category to have a 'category home page', which would all follow the same structure (one headline news story plus n others from the category, together with a separate list of pages from the category).
Now as taxonomy.module automatically puts in links to term pages (taxonomy/term/n) at the top of node view pages (node/n) the simplest thing to do seems to be to override / overload (what's the correct term) the function that draws up taxonomy/term/n. I think I could create my own module that would implement my_mod/n (where n = term id), but then I would have to find a way to hide the taxonomy term links on node pages and insert links to my own 'category home' pages.
Also I assume that creating my own function elsewhere is more sensible than hacking taxonomy.module - correct? So, is there a 'correct' way of doing this within some part of the Drupal API, and if so, what?
Thanks in advance,
James Harvard
Comments
I assume you are talking
I assume you are talking about customising the URI that displays in the address bar in the browser - to do this manually, you can use the URL Alias module included with Drupal core. If you would like it done automatically, you can use the PathAuto module, which is available in the contributed module section of this site. PathAuto will allow you to customise the way in which it overrides the URI.
As for customising what is viewed on category pages, I am not entirely sure what you are trying to acheive, but perhaps you could look at the view modules, available on this site too. I have never used views myself though.
Thanks for your reply but,
Thanks for your reply but, er, no, that's not what I'm talking about!
I want to change the output of taxonomy/term/n pages from the standard blog-style pager output that shows all nodes together.
That said I hadn't noticed the PathAuto module, and it looks like it could be useful for this project.
Refer to the second part of
Refer to the second part of my post, which cites the views module as a potential candidate. You can find the views module here:
http://drupal.org/project/views
Also, it might pay to refer to some of the PHP snippets in the handbook.
Maybe This Helps
I hope I have correctly understood what you need. This is what I do:
Take a look at creating a separate admin theme.
Then you can create an url alias for any taxonomy/term/n page, for example "music", then when you go to example.com/music you get all nodes from taxonomy/term/n listed (you could also use taxonomy/term/n+m or taxonomy/term/n,m to get nodes from multiple terms).
In your template.php use code like this:
Let us know if it worked.
Regards!
Alexis Bellido
Learn to telework
It sounds like
you should investigate the Views module. I can't quite tell exactly what you are trying to do, but I think you'd find Views eye opening anyway and worth looking over.
--
Anton
New to Drupal? | Forum posting tips | Troubleshooting FAQ
Example Knowledge Base built using Drupal
Still trying to do this
I have now experimented with the Views module, which is indeed interesting and well worth a look. One thing I discovered is that it is possible to overwrite existing core Drupal paths with one's own view, but I have yet to get a definitive answer on whether that is by accident or design.
As I effectively want two views on one page, the Views module on its own is not going to do what I want. But having seen that it is possible to override core Drupal paths from other modules, I now think that this might be the best way to achieve what I want.
So, I assume it is possible to create my own module that uses
hook_menu()to register my own callback function fortaxonomy/term/n. This would replace the callback function defined for that path bytaxonomy_menu()- correct?However, even if it is possible to do this, is it advisable? I can't find anything to tell me whether this is an accepted way of modifying or extending Drupal.
You should check out the
You should check out the Taxonomy Redirect module, maybe this is your way. I have no experience with the module yet, but it might fit in your setup.
Code Sample
I required a similar thing, and wrote the following code into my page.tpl.php - hope you can find something helpful in there. If anyone reckons there is a simpler way to achieve this, please let me know.
-Chris
P.S. - the code works around the fact that I have two parallel and matching vocabularies, one for forums, one for everything else. A bit annoying to say the least.
Subscribing, interesting
Subscribing, interesting solution to show the terms and nodes underneath. Greetings, Martijn
Elegant Solution with views and path auto
I've found a very elegant solution to redirect the standard taxonomy listing (taxonomy/term/n) to a view.
1) Create a view with a path. e.g browse/regions
2) With path auto, redirect your specific vocabulary or all vocabularies to the path of your view.
If somebody is trying to pull
If somebody is trying to pull this off in Drupal 7, I sugguest you to look into Taxonomy Display. So far it has worked for me.