I know you can create nodes programmatically by creating a node object and then firing node_save() but I don't actually want to store the node in the database.

Is there a way to create nodes of a specific content type in code that show up in the Find Content screens and work with views etc, but are not physically stored in the database.

The reason I ask is that I have a view that lists a series of nodes of a specific content type, but I want to create a custom node in that list that uses PHP to set the content dynamically but if I fire node_save() will it node get stored in the database every time the module is executed.

I'm also using node reference to link to these nodes so my programatic node will need to work with node reference too.

3 Answers 3


You're trying to do a lot there.

You can do most of what you want without having a node in the database. I think node reference is a sticking point.

Views can be used with a number of back ends, you can get it to point to a different database or index your data with solr and use solr views to search and access your content, there is an issue with using completely external content but you can get round that. Sparql views can allow you to get data from a triple store.

You can populate a node object with fields and use theme node to display it without using node save.

A common pattern is to create stub nodes, which contain only a reference to an external resource and use nodeapi hooks to load the data when the node is viewed. This is often less work and would allow you to use the standard search and node reference functionality.

Without knowing quite why you don't want to save the nodes, it is difficult to make a concrete suggestion.

  • stub nodes sounds like exactly what I need, can you give me a point on how to create a stub node and which nodeapi hooks I would need to use to attach content?
    – Camsoft
    Jun 13, 2011 at 13:17
  • Wow, I didn't know you could use both solr and SQL in a single view. Views is indeed powerful. Do you need any particular work to setup views to use both? hook_views_data or something else?
    – googletorp
    Jun 13, 2011 at 14:26
  • Not a single view. Sorry. On the same page (using context). levelbusiness.com/doc/company/uk/06937730 (current company) has 2 solr sources and an external MySql source as views to render the page. May be switching soon due to performance reasons. But it works. Jun 13, 2011 at 14:53

This link might help:



Node reference works by saving the id of the node that you want to reference. For a node to have a nid, it needs to be saved to the database.

Views works by querying your database. While it is possible to let views use different things to fetch data other than SQL/database it's the only thing I know off that is well supported. I don't believe you can use more than one engine to fetch data, which means that in order for views to get your dynamically created node, you will need save it in the database.

Have you thought about saving a list of the nodes you create instead and update them if needed, instead of create new nodes every time?

  • You can mix solr/sql and sparql views on one page. But can't joins across them. There is a restriction I believe on using pl/sql and Mysql on the same request. Jun 13, 2011 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.