I am seeking help with the following issue: I need to change the output associated with one flexinode type content. I want the overall node to be displayed in a table and the subordinate fields to be wrapped in tr and td tags. A new row will always start after a specific field (say flexinode-textfield-41 then flexinode-textfield-53). Is there an easy way to wrap this stuff in a table rather than div tags?

I've already looked at the time-stamp example in the handbook and I'm not sure how to apply it to this situation (as I am only theming a specific content type and not all flexinode field types). I've seen a patch with some potential, but I'm not sure it works with 4.6 and I'm told it can be done more directly through node calls.

If anyone can get me started, I'd greatly appreciate it.

Comments

bomarmonk’s picture

Thanks in advanced for your suggestions.

Bèr Kessels’s picture

Flexinode allows extrme-power-themeing. You can:
theme each type of field, (theme_fieldname)
theme each type of flexinode (theme_node)
theme the complete node using the pased-along variables $node->flexinode_XX

---
Next time, please consider filing a support request.

[Bèr Kessels | Drupal services www.webschuur.com]

Dublin Drupaller’s picture

Thanks Bèr

The last option worked for me..quick question..do you know how to display an image in the node-flexinode-n.tpl.php file?

Cheers

Dub

------------------------------------------------------------------
anyone else looking for non-programmer instructions on how to theme flexinode content using phptemplate based themes you can do this:

  1. create a node-flexinode-n.tpl.php file and upload it into your /theme/folder (Where n is the flexinode type number that is granted when you create a new flexinode content type)
  2. in the tpl.php file print out the flexinode content fields in whichever way you want, see example below
<div id="special_content">
<div id="flexifield_one"><?php print $node->flexinode_9 ?></div>
<div id="flexifield_two"><?php print $node->flexinode_10 ?></div>
<div id="flexifield_three"><?php print $node->flexinode_11 ?></div>
<div id="flexifield_four"><?php print $node->flexinode_12 ?></div>
<div id="flexifield_weblink"><a href="http://<?php print $node->flexinode_13 ?>" target="_blank">Official Website</a></div>
</div>

Tip: You can find out what the flexinode_number is for each field by going to ADMINISTER -->> CONTENT -->> CONTENT TYPES and hover over the EDIT FIELD link. You should see a link like this in your browser status bar:admin/node/types/edit_field/9 so that field will be called by using the <?php print $node->flexinode_9 ?> code.

-----------------------------------------------------

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

Dublin Drupaller’s picture

Answering my own question here.....

but here's how to display an image in a node-flexinode-n.tpl.php file...

In the following snippet..the flexinode_10 field is for an image. Change the number 10 to suit.

<img src="/<?php print $node->flexinode_10->filepath ?>">

No idea how to get the width and height of the image...will post up here if I work it out.

dub

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

bomarmonk’s picture

Dub and Ber, thank both of you for your help. I'm well on my way to theming my content and I'm getting things to work.

Although, I'm not sure why I am having the following problem: after theming my content with the flexinode.tpl.php file, the book navigation links at the bottom of the page have vanished. I imagine I need to include something else in my tpl.php file so that the node continues to behave like a normal node (showing book nav links, for starters). I'm not sure how to restore this with my custom theming file... any ideas?

Or is there something else strange that is happening here?

Dublin Drupaller’s picture

Hi Bomarmonk...

here's what you need to include before the closing DIV..

<?php if ($links): ?>
    <div class="links">&raquo; <?php print $links ?></div>
    <?php endif; ?>

I tend to look at the node.tpl.php or page.tpl.php file for stuff like that..

Hope that helpse..
Dub

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

bomarmonk’s picture

Dub, thanks again for your willingness to help the less technical users

Okay, I've added the following code to the end of my flexinode.tpl.php file (I had actually checked the page.tpl.template file before posting, but there isn't anything but a footer insert-- the following matches what is found at the end of my node.tpl file):
if ($links):
if ($picture):


endif;

endif;
"Add child page" and "printer friendly" links are now visible, although the book navigation links still aren't there... I've checked the page.tpl.php and node.tpl.php, and I don't see any further insertions at the end of the template files... I must be missing something still.

bomarmonk’s picture

The following statement gets the book navigation links into the page, but it reproduces all of the content (and without custom theming that I've worked on): print $content

So I need to somehow isolate the statement that would call only the additional linking content at the bottom of the $content... possible? I hope so!

Thanks for any additional suggestions or pointers!

Since this is a new question that deviates quite a bit from my original post, I've submitted another post here:

http://drupal.org/node/25567

kfc’s picture

This is my first shot with Drupal and it seams great but now I’m going around in circles. In my flexinode content type I have a table field how can I output that type in a table. I think I need to use the API function theme_table($header, $rows, $attributes = NULL); but no success any help is greatly appreciated.

I understand that the node is a multidimensional array and the following

print_r($node->flexinode_8)
 

returns
Array ( [0] => Array ( [0] => Size [1] => 3/4 Inch = 20 mm ) [1] => Array ( [0] => Filtration Surface Area [1] => 28.5 sq. Inch = 183 cm2 ) [2] => Array ( [0] => Max Recommended Flow Rates [1] => 13 gpm = 3.4 m3h ) )

print_r($node->flexinode_8[0])
 

returns
Array ( [0] => Size [1] => 3/4 Inch = 20 mm )

print_r($node->flexinode_8[0][1])
 

returns
3/4 Inch = 20 mm

Thanks

thinkinkless’s picture

I have been working on the same - specifically to set a max width on the div containing the image so caption fits nicely beneath it.

After looking at the code in depth i think this is something that needs to change in the module. Flexinode uses file.inc (vs) image.inc for processing images. This is not ideal for a couple of reasons. The first is you can't grab the width/height values. The second is it uploads images into 'files/' instead of 'images/'. I checked the CVS and there is no change as of 11/5/05.

Is this the type of thing that should be added as a feature request?

displaying an image when theming flexinode content

zach harkey’s picture

I think the reason for this is that flexinode doesn't want to be coupled with the image module since it isn't part of the core. People would not be able to upload images unless they had the image module installed.

I don't see why we couldn't have 2 different versions of the the image fields because so many people actually want to use the image module. Or maybe it could use the image module 'if' it existed, and otherwise use file.

-zach
------------------------
harkey design

: z

thinkinkless’s picture

I hadn't thought if image module inclusion and did not realize that this was the reason for the image.inc file.

Or maybe it could use the image module 'if' it existed, and otherwise use file.

This seems like the perfect solution!
Is this a feature request?

thinkinkless’s picture

I solved one of my own concerns about fleximode images and figured i would share it here. You can grab the image attributes using php as such:

<?php
list($width, $height, $type, $attr) = getimagesize($node->flexinode_1->filepath);
echo "$width, $height, $type, $attr";
?> 

Test it for yourself and you will see the options that print. For my purposes it will allow for a container with an image (flexinode_1) and caption below (flexinode_2), and the container width can now be restricted to the image '$width'.

I hope someone else finds this useful!

magnestyuk’s picture

theming flexinode on the field level might be simpler this way:
http://drupal.org/node/26398

jpcesar’s picture

Hi...

How to print the Default Title field ? I've tried

print $node->flexinode_0

but no luck.

Another thing. Before I customize the template I had 2 layouts. One the teaser, and other the content page. Basically in the teaser i showed the 10 last items and when i click on one it goes to that item page.

Now i see this template modified the teaser. how can I link to the node page?

Best regards

arthurf’s picture

A little late, but...

you can just do $node->title

the command print_r($node) is your friend- you can see all the parts of a given node and then figure out what you want to grab.

amanda’s picture

This is huge--I have been trying for days to figure this out, to no avail. I've got it working nicely except that my flexinode type uses a couple of select fields, one for state and a few others. For those fields I don't get a text value back, I get a number. So while

print $content says that we are talking about a bill from New Hampshire,

print $node->flexinode_2; returns simply "31." How do I get it to lookup 31 in the list of options? I am guessing that this is going to be an issue when I get into formatted text areas as well.

Dublin Drupaller’s picture

Hi Amanda,

I too am working on phptemplating flexinode content..and came up against a similar issue...there's probably a much easier way of doing this...such as creating an array....but I'm not a programmer.

the following is laborious if you have a lot of options..but it works.

<?php if(($node->flexinode_12) == "1"): ?>option 1<?php endif; ?>
<?php if(($node->flexinode_12) == "2"): ?>option 2<?php endif; ?>
<?php if(($node->flexinode_12) == "3"): ?>option 3<?php endif; ?>
<?php if(($node->flexinode_12) == "4"): ?>option 4<?php endif; ?>
<?php if(($node->flexinode_12) == "5"): ?>option 5<?php endif; ?>

hope that helps..

Dub

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

amanda’s picture

that is intense, but not impossible.

The last bit is that I have now totally overridden any distinction between the overview pages (which show teasers) and the node pages which show a whole node. I am sniffing around the handbook for a the variable that lets me know whether the page I am on is a list of nodes or the node alone.

vwX’s picture

call the flexinode_load_fields function with your field_id # ($field1 = flexinode_load_field(1);)

Then do something like $field1->options[$node->flexinode_1] in your code.

Have fun and check my Drupal Profile: http://drupal.org/user/519

patrickharris’s picture

So, what should I do exactly, if I'm trying to retrive the value of a checkbox in a flexinode?

Dublin Drupaller’s picture

I'm not certain how the Vxw was hinting towards...but a poormans way of doing it..would be to do this:

I'm using a flexinode field number 12 as an example..

<?php print $node->flexinode_12: ?>

Usually a checkbox is either on or off..1 or 0...so if you were using it for a condition, you could

<?php if(($node->flexinode_12) == "1"): ?>
<?php print "the person selected the flexinode 12 checkbox"; ?>
<?php endif; ?>

Hope that helps..

Dub

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate

patrickharris’s picture

That works of course, but it seems like a nasty hack. What happens if the checkbox name is changed ... I'd like to be able to access the name itself.

vwX’s picture

the flexinode_load_field funtion loads the option values into an arry that you use in your code.

Your code:

<?php if(($node->flexinode_12) == "1"): ?>
<?php print "the person selected the flexinode 12 checkbox"; ?>
<?php endif; ?>

Flexinode way:

<?php  $field_values_for_flexinode_12 = flexinode_load_field(12);?>
<?php  echo "The user selected :"  . $field_values_for_flexinode_12->options[$node->flexinode_12];?>
?>

Have fun and check my Drupal Profile: http://drupal.org/user/519

JohnG-1’s picture

If only I understood it more :(

I'm looking for a way to populate a flexinode drop-down field with a list of members' names from 'name' field in the 'users' table in the database. The idea is to automatically update the options list as the website membership changes ...

As I understand it, flexinode theming deals with the presentation of node data. And vwX's hint calls the array from flexinode data. I wondered if this method could be used to call an array of data from another module(?) and insert it dynamically into a (flexinode) option_field.inc ...?

I'm no programmer so any advice on concept and syntax welcome!

dtabach’s picture

I'm learning a lot from reading this topic, thank you all!
I'd like to ask a question that your Hint above almost answered:
I have a flexinode_timestamp which was customized according to these instructions .
Then, in my node-flexinode-x.tpl.php I wrote:

<div class="yearprojct">year of project: <?php print $node->flexinode_6?></div>

where flexinode_6 is a timestamp, formated to show only the year.
But I get a big number such as '762784440' instead of the expected '1994', which is the year of the project.
What is the code to print the actual year?

Durval Tabach
(drupal newbie at archiclube.org)

Durval Tabach

briandelicata’s picture

Anybody managed to convert unix timestamp to regular date in flexinode display?

Brian

zach harkey’s picture

Extreme-power-themeing!

- I love it.

-zach
------------------------
harkey design

: z

chanon’s picture

A very informative thread! At last I can theme flexinodes. Thanks all of you.

I wonder if this stuff is in the documentation, because I didn't see it.

3dsoft’s picture

well to be honest, theming is a mess for a webdesigner and not straight forward!

so long

tomski777’s picture

To be fair, Drupal allows you to theme content in an incredibly flexible way & once you get over the initial learning curve (which is admitably pretty steep) life is much easier than allot of other CMS's I've used, which (tend to) have an easy way of doing things initially, but you soon end up being very restricted when you try to do something more complex.

I am by no means over the initial curve! but I am starting to see just how much power & flexibility this system offers, which I believe is more than worth the effort.

Just my 2 pence worth ;)

><>tomskii
><>www.mutinyarts.co.uk

3dsoft’s picture

Indeed, it looks very flexible to me, which I like. But either I do not see a good documentation on how to theme flexinodes or they just don't exist.

Speaking of other cms systems, I love the way you can design a theme in Typo3 with Templavoila!

bomarmonk’s picture

Drupal, as mentioned above, has a bit of a learning curve. But I'm getting over the hump in terms of finding solutions for what I need Drupal to do. This is, for the most part, due to the wonderful community that surrounds Drupal. Thanks again for all of your help!

(the solution to the other flexinode theming issue -- including all book links, etc.-- can be found in an aforementioned post in an earlier part of this thread-- thanks again to another Drupal member willing to help me out!)

jpcesar’s picture

Hi :)

What about the teaser? How can I make a different theme for teaser and inside one specific node ?

For instance:

http://www.noiseblock.net/taxonomy/term/9

When you click on the Title i made a custom link to go to that node's page but i did not want the review text to show in the teaser :|

Any ideas? Thanks

zach harkey’s picture

For this example let's assume the following:

1) Your flexinode is "flexinode-2"
2) It has 2 fields: "flexinode_11" and "flexinode_12"

3) The summary view (teaser) should display...
1. flexinode_11
2. links

4) The extended view should display...
1. flexinode_11
2. flexinode_12
3. links
4. terms

You would put something like this in your node.tpl.php:

<?php if ($node->type == flexinode-2): ?>

    <?php if ($page == 0): /* Summary view */ ?>

        <div class="summary">
            <div class="content">
                <?php if ($node->flexinode_11): ?>
                    <div>
                        <?php print $node->flexinode_11 ?>
                    </div>
                <?php endif; ?>
            </div>
            <?php if ($links): ?>
                <div class="links"><?php print $links ?></div>
            <?php endif; ?>
        </div>

    <?php else:  /* Extended view */ ?>

        <div class="extended">
            <div class="content">
                <?php if ($node->flexinode_11): ?>
                    <div>
                        <?php print $node->flexinode_11 ?>
                    </div>
                <?php endif; ?>

                <?php if ($node->flexinode_12): ?>
                    <div>
                        <?php print $node->flexinode_12 ?>
                    </div>
                <?php endif; ?>
            </div>
            
            <?php if ($links): ?>
                <div class="links"><?php print $links ?></div>
            <?php endif; ?>

            <?php if ($terms): ?>
                <div class="terms">( filed under: <?php print $terms ?> )</div>
            <?php endif; ?>
        </div>

    <?php else; ?>

         /* Your default node template stuff */ 

<?php endif; ?>

-zach
------------------------
harkey design

: z

jpcesar’s picture

I've done almost that way, but instead of modifying the node.tpl.php i've modified flexinode-2.tpl.php :)

Thanks!

Another thing... when I use print $node->flexinode_X if I want to format the HTML, and replace the linebreaks with HTML code, how do I do ?

I've found format_date for dates, but how to correctly display text, parsing the linebreaks automatically ?

Best regards

zach harkey’s picture

<?php print check_output($node->flexinode_x) ?>

-zach
------------------------
harkey design

: z

robomalo’s picture

I have been looking for this little piece of information forever!!!

<?php print check_output($node->flexinode_x) ?>

Is there a resource or some kind of documentation with all kinds of this type of information for themeing flexinodes?

zach harkey’s picture

If there is I haven't found it. The only really helpful information I have been able to find was this page in the handbook, and a little in the Read Me(which was actually where I had my aha! moment)

So far my method for figuring each one out is pretty trial and error. Aside from a couple of books, almost all of my php knowledge to date has come from trying to theme Drupal, but I'm getting much better at getting it to do exactly what I want. Believe it or not I've managed to 'extreme' theme every one of the available content types.

I usually start by building a standard flexinode with whatever fields I want, then I just dump the whole $node object onto the page inside some <pre> tags and see what I can understand and make sense of. If I can't understand something I search the drupal api. If that doesn't shed any light, I dissect the actual module code. Usually there are some clues about how to use something

There needs to be a full section in the handbook, perhaps a flexinode theme snippet repository. I've been developing some theming documentation, including a huge pile of flexinode examples. I will do my best to clean them up and share them as soon as I can.

Until then, don't overlook the forums. Like I said, I've successfully themed most of the flexinode components. Just tell me which one you are having trouble with and I, or someone else will paste in a snippet like this one.

-zach
------------------------
harkey design

: z

xeeya’s picture

Thanks a lot for all your explanations for theming flexinode. Since there is no complete documentation of it, every hint is needed. Especially for me ... I`m not a programmer ^^

I tried your trick for the teaser, Zach, but I`m just getting a parse error. Also I`m not sure about the other flexinode-types you all haven`t talked about yet. For example: What about the screenshots-field? I haven`t found out yet how to get this right into a template. Maybe someone can give me another hint? I haven`t found out how to build in the file attachment-field either .. :(

Since I use all types of flexinodefields it`s very difficult for me to theme a complete type of flexinode. I`m sure I`m not the only one.

But: The hint for the images and the select-fields are great. Thats information I searched for a long time! :D thanks a lot!

zach harkey’s picture

Post your code up here and we can look at it.

-zach
------------------------
harkey design

: z

akakoko’s picture

This is what works for me so far. As a drupal-newbie I am sure this code needs improvement. Looking for more information I found this thread and maybe this code helps a little.

Because I didn't see the wood for the trees I didn't use the many php-tags and used single quotes for the print statement.

There are two sections 'if ($main)', the code for the teaser, and 'if ($page)', where the code to view the full node goes. $node->flexinode_14 is a line which I want to print before the title.

<?php
  if ($sticky) {
    print '<div class="node sticky;">';
  }

  if ($picture) {
    print $picture;
  }

  if ($main) {
    print $node->flexinode_14;
    print '<h2 class="title"><a href="/' . $node_url . '">' . $title . '</a></h2>' . '<div><img src="/' . $node->flexinode_16->filepath . '" /></div>';
    $teaser = node_teaser($node->flexinode_17);
    $teaser = check_output($teaser);
    print $teaser;
  
    if (strlen($teaser) < strlen($node->flexinode_17)) {
      print '<div class="links">' . $links . '</div>';
    }
  }
  
  if ($page) {
    print $node->flexinode_14;
    print '<h2 class="title"><a href="/' . $node_url . '">' . $title . '</a></h2>'  .  '<div><img src="/' . $node->flexinode_16->filepath . '" /></div>';
    print $node->flexinode_17;
  } 

  if ($main) {
    print '<div class="end">&nbsp;</div></div>';
  } 
?>
drupalxykon’s picture

Hi,

I see examples in this thread for printing text and images. How do I print a field of type 'file' in node-flexinode-x.tpl.php ?

drupalxykon’s picture

nevermind

print $node->$field->filepath; "> print $node->$field->filename; works

where $field is flexinode_$field_id

kulvik’s picture

That's the question :S

- Thomas -

"If I do this, he might kick me back. That's not what I want. So I break his arm" - Bas Rutten

astra’s picture

If create a field 1 with the field_table type and use

print $node->flexinode_1

I get the text "array" output, but without any data inputted to the table.

How to print a field of the type field_table in node-flexinode-x.tpl.php? Thanks!

akakoko’s picture

var_dump($node) shows that $node->flexinode_1 is an array of the rows where each row includes an array describing the fields.

For example, you can access the second field of the first row with:

print $node->flexinode_1[0][1];

or you can iterate through the array of the first row to print each field of this row:


$foo = $node->flexinode_1[0];

foreach ($foo as $bar)
  {
     print $bar;
  }

Hope it helps!

arthurf’s picture

I got a bit confused by this one, and discovered that i need to do this:

print check_output($node->flexinode_X, $node->flexinode_X_format)

where X is the value of your field. this way you get your filter output on your field. and now glossary works right!

astra’s picture

Great! I want to get the image filter on the field_textarea of flexinode.

tatere’s picture

pretty sure that check_markup is the new version of check_output

estraver’s picture

This the second night to get a theme working for flexinode. Can anyone tell wat I must do. Must I install this patch: http://drupal.org/node/10937?

I made a flexinode.tpl.php -> does not work
I made a node-flexinode-1.tpl.php -> does not work
I made a flexinode-1.tpl.php -> does not work

Must i make a callback function in template.php? I can't read all of this in the manual. Hope someone can help me out.

akakoko’s picture

I didn't install any patch. Is '1' the right number of your flexinode? Try to copy node.tpl.php in your default theme directory to node-flexinode-1.tpl.php and change just a little html/css to see if it works.

romany’s picture

It might seem obvious but just in case...

If you want to customise the Title [the default (flexi)node field] you need to call it as print $node->title; in your node-flexinode-n.tpl.php.

Cheers

Roman

JohnG-1’s picture

does anyone know how to grab the 'name' of the node-type?

I mean the name the admin gives when creating a new node-type; not 'flexinode-1' but the custom label eg 'event'.

xeeya’s picture

Is there any way to get an output of the count of comments in flexinode? This would be helpful for theming the teaser and the comments-section of the article.

thinkinkless’s picture

this is what i use in (eg) flexinode-1.tpl.php

<div class="submitted"><?php print 'article - ' .l("$node->name","user/$node->uid"). ' - ' .format_date($node->created, "custom", "F j, Y"). ' - ' .$node->comment_count. ' comments';?></div>

returns:
article - someuser - December 1, 2005 - 0 comments

xeeya’s picture

hey, thanks a lot. works fine. :D

xeeya’s picture

This thread is already a little bit older, but I got one special question that perfectly fit here. Im sure the question is pretty easy for php-experts ;)

I got the idea to create fully themeable overview-pages with flexinode, so that I can change the complete layout for other themes. For example I created a custom overview-page for articles, that is flexinode-2, and I`ve put one of the php-snippets in it, which shows all articles with teasers.

The problem actually is, that code like print $node->flexinode_6 don`t output anything. I use some fields only for the teaser. Also to get the comment count doesn`t work.

So is there any way to out the flexinode-fields from another flexinode in a flexinode?