I have spend quite some time looking through the Handbook but I can't seem to locate any sample code for php boxes or "static" php pages. While there are sections describing how to make modules and themes, I can't find any that give examples for pages and boxes. I'd suggest that this would be very helpful for the large number of people like me who are not professional programmers but who can figure out how to tweek code appropriately.
For example, what would the php code be in order to return all the titles for nodes associated to a particular taxonomy (e.g. tid=5) in a page. What if one wanted to return the five Imost recent nodes associated to a particular taxonomy? What if one wanted the titles and the summary details, or the titles and the complete details, etc.
Similarly, it would be useful to provide examples for boxes. I had to learn the hard way that for boxes the code must end with a "return" statement whereas for pages a "print" statement should be used instead.
If such guidelines/examples already exist, then IMHO they could/should be made more visible in the handbook.
Thanks in advance for any feedback that I get on this.
Comments
I have not gotten that far yet but...
The manual does have 25 to 30 pages of links to sites and their description. I downloaded and created a MDI file to read offline. It was 234 pages. But I got frustrated when I saw that 30 pages were site links. I am all for dropping these in place of some more database information and example code.
---------------------------
info for Drupal installation
__________________________
Carl McDade
Information Technology Consult
Team Macromedia
www.heroforhire.net
Autogenerated
The drupal sites list is generated automatically by sites that ping drupal.org using drupal.module.
Have a glimpse at Drupaldocs.org
Hi,
I also feel a little bit sad not to have much examples code connected to handbook, it should be very usefull.
Well I do find a little more help, maybe it can help you, havec look at http://drupaldocs.org/ and search for "example", you will find code for writing node, block...
PHP to list nodes associated to taxonomy in block
Here is the PHP code for a block to list the last five nodes associated to a taxonomy, in this case tid=17.
Clearly, you can modify the HTML used here as well as add ID and/or CLASS tags for use with CSS styles.
Thanks go out to CyberSteph for his help with this.
Hope this helps a bit,...
I'd have to agree with you about the documentation, I remember having exactly the same problem when I started using Drupal.
Here's some code samples, I checked it for the 4.4.0 release (although there shouldn't be much difference).
** Return 15 titles for taxonomy:
** Five most recent posts for block:
** Listing nodes with summary:
** Listing nodes full:
-------------
MultipleX
Don't click this if you don't know Farsi!!! :)
www.hambastegimeli.com
Need to test with 4.5 but thanks.
I'll try to do some test with 4.5 but in the meantime thanks for your input! I'll post more samples as I come across them. Who knows, maybe there is a section in the Developper Handbook to put this kind of thing but I still haven't found it.
Doesn't Seem to work for v4.5.x
Any input as to why this doesn't work for v4.5? Here are the errors:
Regards,
Czar
Please do not start a new
Please do not start a new threadm, but add your custom blocks *as child pages* to http://drupal.org/node/17170
And if this solved you problem, would you be so kind to report back that it helped? This will help others whom are looking for the same solution.
[Ber | Drupal Services webschuur.com]
Unfortunately, the page with samples is no longer...
...where it was? Does somebody know where it is?
Click on custom blocks and
Click on custom blocks and then examples.
-sp
---------
Test site, always start with a test site.
Drupal Best Practices Guide -|- Black Mountain
-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide