Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By slayerment on
I am trying to display data from my flexinode and am having trouble trying to figure out just how to query it.
What I would like to do is display nodes like how they show up when listed in taxonomy, but I would also like to be able to use variables like $node->flexinode_3. I basically want to be able to list certain elements from my flexinode in a loop anywhere on my site.
Any help is always appreciated.
Thanks :).
Comments
Anybody?
Anybody?
Try this
It may not be exactly what you are after, but it should give you some clues.
I hope that gives you a start.
Still no luck
Thank you very much for the reply. I tried using the following code but I think I am doing something wrong. Nothing is appearing for me. Any thoughts?
I'm interested too....
I have been wondering about using Flexinode more.... errr, flexibly - myself, so I'm interested in whatever you may find out.
If you are getting nothing at all from the print statement then this is probably because you the property "flexinode_5" does not exist for the $node object.
Have you tried just doing a "print_r($node)" which will print out all the properties of the object and their values?
I tried print_r($node) but
I tried print_r($node) but that didn't do anything either.
Would this
Would this work?
Your initial codes uses the $nid variable which equals to null since it's not initialized. $node->nid would be the nid grabbed from the database with your sql query.
Show Flexinode Data
Your flexinode data is not in the node table, so you need to 'JOIN' the node to the flexinode data. Here is a long and complex looking example, but just paste the code into a node that is php code and set ctype_id and run it. This will show a table view of the flexinode fields in a node if they are selected to 'Show in table' for that flexinode type. Uncomment the print $sql line to see the sql code required to include the flexinnode fields in a query.
Full control of the output format
If you want to take full control of the output you may put your data inside an array like
Use this as a php snippet as described above
can you send example?
it look very nice, but can you send example of part "//build your own output format here" ? ... I have flexinode with only one label - "name" ... And I would like to make list of them ... I would like to use it for list of gags of my friends ...
I try this:
$output .= '<div>'.print($row[title]).'</div>';
but output is:
why are there "1" ?
Are you setting the correct
Are you setting the correct flexinode id number in $ctype_id? Besides not using quotes around your string literal array index 'title' I can't see something wrong. May be you actually have this 4 rows? Try printing the whole $rows array to get an idea whats going on.
BTW, this one in my snippet above is wrong because it does not check for the count of items in $rows:
Replace it by
apology
I play with it again, and I use your function "print_r" ...
$output .= '<div>'.print_r($row['title'], 1).'</div>';
and it works fine.(I changed "print_r" on "print" at the start of my experimentation, and output appended char "1" for each one node to the end of the output. It's my stupidity, I actually don't know why I changed it...(I'm really not php expert:) ) )
So sorry, your code is correct and really very useful! THX
This script looks very
This script looks very useful to customize the output of flexinode types. I'll try it later on.