Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
Except I wouldn't mind it to be ordered by the latest added and not the latest changed. And also, can it be set to content type, ie. I want only nodes from flexinodes1-5 and not comments/blogs/forums?
Thanks for posting back, including the extra edit. Unfortunately I can't get this to work. It's calling whatever the first flexinode is set to, but ignoring the second one. I've tried it with the flexinode% and with () and the OR statements, but none of them have worked.
When I used two flexinodes in the SQL with the OR, I switched the order and it returns always the first one. :-/
I checked and doublechecked things like spaces and apostrophes. No avail.
Hm, I tried it on my site and it seems to work...
here is a piece of code that works for me, I only have 3 flexinode types so I chosed to call for all but nr 1 ...
<?php
$listlength="10";
$output = node_title_list(pager_query(db_rewrite_sql("SELECT n.nid, n.title, n.created FROM {node} n WHERE n.type REGEXP 'flexinode-[2-3]' AND n.status = 1 ORDER BY n.changed DESC"), $listlength));
$output .= theme('pager', NULL, $listlength);
print $output;
?>
You're a star...works a treat. Many thanks. The order in this thread is not so clever, so just to clarify, it was the REGEXP bit that sorted it out.
Maybe you should add it to the PHP snippets. It is a useful piece of code and there is nothing there yet that says how to pull node titles from multiple flexinode types.
__________________ http://www.wilba.org
Great posts. I especially like the tip on posting multiple node types. I know most of this is in the php snippets portion of the handbook, but I figured this is a more active thread to ask a question. One problem I've had with snippets though is they don't seem to respect node access. For some sites I use Organic Groups to control access but when I use snippets all the content shows up regardless of access permissions for the node. Does some type of call need to be made to OG for the permissions?
Also, if I wanted any nodes with promoted status to show up (I think n.promote = 1) would I have to specify every node type in the snippet, or just not have the whole WHERE n.typ portion? Thanks.
If I'm not mistaken, pulling the nodes from the node_title_list function means that it filters its results to comply with current permissions and access controls. Haven't needed to test it though.
If I use drupal/node page my front, it automatically shows snippets of last few posts which have promoted to front page option set. Can I get exactly the same facility in the frontpage module, with its additional flexibility? I think this feature was there in frontpage module previously (I am not sure about it, even though)
PROMOTED TO FRONT PAGE Example snippet
----------------------------------------
The default front page when you install Drupal for the first time, is 'node' which displays a list of node teasers, where the nodes have been tagged as pages that are 'Promoted to Front Page'.
If you want to recreate that node listing after installing the front_page.module, simply paste the following snippet into the text area provided on the front_page settings page and select the PHP filter before saving your new configuration.
Comments
I'am not shore that I
I'am not shore that I understand what you mean here but..
You could use a php snippet like this, to generate a list of the X latest changes with a pager
This is pretty close to what
This is pretty close to what I want. :-)
Except I wouldn't mind it to be ordered by the latest added and not the latest changed. And also, can it be set to content type, ie. I want only nodes from flexinodes1-5 and not comments/blogs/forums?
___________________
http://www.wilba.org
I think you could change
I think you could change ORDER BY to "n.created "and set WHERE to reflect the type you want...
If you want all flexinode types I think you could set WHERE to sometning like ... WHERE n.type LIKE 'flexinode%'
- if I remember correctly..
EDIT: I'm so sorry - I didn't remember that correct..
To get all type names starting with flexinode it should be WHERE n.type ='flexinode%'..
You could use regexp and set
You could use regexp and set WHERE to something like
Hi Gabriella
Hi Gabriella
Thanks for posting back, including the extra edit. Unfortunately I can't get this to work. It's calling whatever the first flexinode is set to, but ignoring the second one. I've tried it with the flexinode% and with () and the OR statements, but none of them have worked.
When I used two flexinodes in the SQL with the OR, I switched the order and it returns always the first one. :-/
I checked and doublechecked things like spaces and apostrophes. No avail.
Hm, I tried it on my site,
Hm, I tried it on my site and it seems to work...
here is a piece of code that works for me, I only have 3 flexinode types so I chosed to call for all but nr 1 ...
You're a star...works a
You're a star...works a treat. Many thanks. The order in this thread is not so clever, so just to clarify, it was the REGEXP bit that sorted it out.
Maybe you should add it to the PHP snippets. It is a useful piece of code and there is nothing there yet that says how to pull node titles from multiple flexinode types.
__________________
http://www.wilba.org
Node Access
Great posts. I especially like the tip on posting multiple node types. I know most of this is in the php snippets portion of the handbook, but I figured this is a more active thread to ask a question. One problem I've had with snippets though is they don't seem to respect node access. For some sites I use Organic Groups to control access but when I use snippets all the content shows up regardless of access permissions for the node. Does some type of call need to be made to OG for the permissions?
Also, if I wanted any nodes with promoted status to show up (I think n.promote = 1) would I have to specify every node type in the snippet, or just not have the whole WHERE n.typ portion? Thanks.
If I'm not mistaken, pulling
If I'm not mistaken, pulling the nodes from the node_title_list function means that it filters its results to comply with current permissions and access controls. Haven't needed to test it though.
If you want any node type
If you want any node type just take out the n.type
or if you just want certain node types, like stories and images,
.
.
Behave as in case of "Node"
If I use drupal/node page my front, it automatically shows snippets of last few posts which have promoted to front page option set. Can I get exactly the same facility in the frontpage module, with its additional flexibility? I think this feature was there in frontpage module previously (I am not sure about it, even though)
it's in the front_page.module readme.txt
Hey Sajitchvk,
From the front_page.module readme.txt
Phil
Thanks!
Thanks PhilK, I was looking for exactly this simple thing...