Hello all,

I created flexinode-1 with the flexinode module and then created node-flexinode-1.tlpl.php,placed in my selected phptemplate theme current folder. Very good result, I'm able to show/hide precisely all the fields of flexinode-1 and associate them with CSS design.
http://drupal.org/node/25055#comment-43801 thanks to Dublin Drupaller

But the problem is that I need to associate this same flexinode-1 to another phptemplate in order to get a different second presentation of the same flexinode-1 showing and masking some fields. How I can do that ??? I didn't read anything about this possibility in the phptempate book or the forums.

I know that sections.module could have been a solution but it won't work with Drupal 4.6 on my online site and crashed with the beta 1 version 4.7 that I installed locally. To bad because sections.module give you apparently the possibility to associate the same node with differents phptemplate folder.

So is anybobody have a clue ? Is there a php script able to associate a choosed flexinode with several phptemplate (with different paths) ? Or other way to do that with phptemplates?

Comments

simon rawson’s picture

I'm a bit confused as to what you are trying to do?

Are you trying to make a template for your flexinode in an additional theme?

If so, just copy the file node-flexinode-1.tpl.php into the directory of the other theme.

This can't be the answer you're looking for, but I'm not sure how else to help. You can have a version of node-flexinode-1.tpl.php within each theme directory. I would imagine that you could also place it in the theme engine folder, if you wanted to apply to all themes (with that engine) unless overridden by a file in the theme directory.

Does this help?

clo75’s picture

First my english is far from perfect, so I will try to explain a little deeper the problem, also it's not an easy one to explain:

This needs described here belong to a more complex problem.
I wanted to show to "Anonymous users" some selected parts (with css instructions) of the flexinode-1 fields and some other selected parts to "Authenticated users".

First part of the needs ;
Let's assume that flexinode-1 have the four following fields : Title(1), Body text(2), Image(3) and URL(4)
Scenario A- Anonymous users will see fields 1 and 2 of flexinode-1
Scenario B- Authenticated users will see fields 1, 2, 3, 4 of flexinode-1

So I want to have two differents phptemplates for "Anonymous users" and "Authenticated users" related to the same flexinode-1 in order to be able to select the differents neede fields. Also it will allow me to do differents design if I associate the four fields with DIV CSS.

Second part of the needs :
I would like to associate this 2 differents displays (Scenario A and scenario B) with the front_page module who offers the option to display different front pages to Authenticated Users (logged in) and Anonymous users (not logged in).

So the main question is how associate the same flexinode to 2 differents phptemplates (exemple node-flexinode-1a and node-flexinode-1b in order to use two different CSS for the selection and presentation of the differents fields of flexinode-1 ??
And if I can do that what will be the two paths to use in front_page.module ??

Thanks for your help, I try to do that since several days but I just done little progress right now.

P.S. : I've tried sections.module (for exemple this module can link two phptemplates folder with two paths) but with 4.6 it's doesnt work on my 4.6 configuration and with 4.7 beta 2 I got crash when I enable the sections.module.

scroogie’s picture

Why dont you just use an if-statement in the flexinode template to decide what you want to print out?

clo75’s picture

As I forget to mention I'm not a php developper...I was looking for a simple phptemplate solution associated with the front_page module, but perhaps it needs also somephp code.

Basically I want to associate in the front_page module two phptemplates themes folders with the same flexinode in order to have two different pages displays : one for the Anonymous and the other for Authenticated users. Using phptemplate will allow to fine tunes which field to display and write CSS to style it. So having two phptemplate for the same flexinode allows to have two different presentation.

Anyway many thanks for your advice for the if-statement but I have to make some big progress in my PHP understanding ;-) !!!

simon rawson’s picture

Well, I'm afraid you probably will need to learn some php for this... although not too much.

You will only need one template file, but within the template you can access variables and make decision about what to output. For example you can get the global variable $user and then $user->roles is an array of the roles which the current user belongs to.

In fact, even simpler, unauthenticated users will have the user id (uid) = 0, so just do a check on $user->uid.

clo75’s picture

So my first try in PHP... I'm sure that some developper will have an attack when seeing this PHP syntax ;-) ... Anyway I put this code directly in the node-flexinode-2.tpl.php

<?php
global $user;
if ( $user->uid ) {
// This should only be true if $user->uid is set and non zero
// Do something for people logged in
<div id="flexifield_title"><?php print $title ?> </div>
<div id="flexifield_four"><img src="/ <?php print $node->flexinode_4->filepath ?> "></div>
<div id="flexifield_five"> <?php print $node->flexinode_5 ?> </div>
<div id="flexifield_six"><img src="/ <?php print $node->flexinode_6->filepath ?> "></div>
<div id="flexifield_weblink"><a href="http:// <?php print $node->flexinode_10 ?> " target="_blank">Visit the site</a></div>
}
else {
// Handle the case where the person is not logged in
}
?>
<div id="special_content"> <?php print $title ?> </div>
<div id="flexifield_five"> <?php print $node->flexinode_5 ?> </div>

But the flexinode-1 fields aren't correctly displayed at all.
Also I got "parse error, unexpected in .../node-flexinode-2.tpl.php on line 6" when I click on one of the differents flexinode link titles .

dublin drupaller’s picture

Hi Clo,

Try doing it this way:

<?php global $user;?>
<?php if ($user->uid);  ?>

<div id="flexifield_title"><?php print $title; ?> </div>
<div id="flexifield_four"><img src="/ <?php print $node->flexinode_4->filepath; ?> "></div>
<div id="flexifield_five"> <?php print $node->flexinode_5; ?> </div>
<div id="flexifield_six"><img src="/ <?php print $node->flexinode_6->filepath; ?> "></div>
<div id="flexifield_weblink"><a href="http:// <?php print $node->flexinode_10; ?> " target="_blank">Visit the site</a></div>
<?php endif; ?>

<?php if (!$user->uid);  ?> 
<div id="special_content"> <?php print $title; ?> </div>
<div id="flexifield_five"> <?php print $node->flexinode_5; ?> </div>
<?php endif; ?>

There are no set rules and there are a number of ways of doing this...but, i tend to use the following snippets for doing conditional stuff in tpl.php files....

<?php if ("condition");  ?>
Display HTML or a mix of HTML/PHP pasted here if the condition is true. Where condition might be something like "if ($user->uid)" which checks to see if the user is logged in.
<?php endif; ?>

I hope that helps

Dub

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

clo75’s picture

Hi Dub,

As you see I try to use your very good flexinode fields tricks you gave earlier on this forum.

Thanks for your script, however i've got
Parse error: parse error, unexpected T_ENDIF in /home/..../themes/leaf/node-flexinode-2.tpl.php on line 8

simon rawson’s picture

I think that your if statements should have colons not semicolons.

<?php if($condition) : ?>

Try that.

clo75’s picture

<?php global $user;?>
<?php if ($user->uid): ?>
<div id="flexifield_title"> <?php print $title; ?> </div>
<div id="flexifield_four"><img src="/ <?php print $node->flexinode_4->filepath; ?> "></div>
<div id="flexifield_five"> <?php print $node->flexinode_5; ?> </div>
<div id="flexifield_six"><img src="/ <?php print $node->flexinode_6->filepath; ?> "></div>
<div id="flexifield_weblink"><a href="http://<?php print $node->flexinode_10; ?> " target="_blank">Visit the site</a></div>
<?php endif; ?>
<?php if (!$user->uid): ?>
<div id="special_content"> <?php print $title; ?> </div>
<div id="flexifield_five"> <?php print $node->flexinode_5; ?> </div>
<?php endif; ?> 

You're right Simon.... with colon it works !!!! thank you very much !!! and many thanks also to Dub too for give me a big part of the solution !!!
It's end me many time spend searching

dublin drupaller’s picture

Hi again Clo,

As a tip, I'm working on a module patch for flexinode called flexiMAX...which allows you to specify custom layouts across all themes for Flexinodes.

If you want to override those flexiMAX layouts, you can simply upload a node-flexinode-n.tpl.php file and Drupal automatically picks it up as the desired layout for that Theme.

I've uploaded a screenshot to illustrate how flexiMAX works and uploaded a 4.6.x version of the module in my sandbox if it's of use. It's sitting there until we iron out one or two added features, before formally submitting it as a patch. It should be fairly self-explanatory from the fleximAX screenshot.

The original FlexiMAX: the holy grail of theming flexinode teasers and nodes.... is quite lengthy, but, there's a good discussion/more tips there if you need more info.

Hope that's also of use to you...

Dub

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

clo75’s picture

Before opening this thread I tried your excellent Fleximax... But I realised that is mostly for fine tuning Flexinodes teasers/nodes ? Or miss I something ??

Anyway Fleximax is a very good and welcomed addition to Flexinode.

One more time many thanks for your decisive post who helps me to resolve my problem

Cris

scroogie’s picture

Does Fleximax already run with Drupal 4.7?

dublin drupaller’s picture

Kiev1 posted a patched version of fleximax.module to work with 4.7 but I haven't had a chance to try it yet.

We're trying to tidy up some other issues with flexinode while updating it for 4.7

dub

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

dublin drupaller’s picture

you're welcome.

FlexiMAX offers site-wide layout control of flexinodes at the $content level.

So regardless of the theme selected, the FlexiMAX layouts will be picked up.

or in other words, if you wanted the same custom flexinode layout to work with multiple themes, FlexiMAX is ideal.

Dub

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

astra’s picture

I am trying a custom flexnode layout. I think using flexiMAX will be a good solusion.