Hi,
I need to create a very custom and non-standard layout home page for a site.
So far I've determined I can use flexinodes to allow cms control over several differently styled panels that make up the design of the home page.
However so far I've only gotten them onto the home page by checking the 'publish to home page' box on content creation which seems a less than ideal means of achieving this.
What I need to do is include the 5 flexinodes in the appropriate areas of the custom home page template file I have running already. This would seem a more robust solution.
I've tried PHP includes and this shows up the static html of the included flexinode template file I tested it on, but the actual dynamic content is not displayed.
Is there a way to do this within Drupals phptemplate engine without breaking the dynamic content in each of the 5 flexinode templates I will be pulling into the home page?
--
How I'm customising 5 content panels and making the content administrable via template files with Flexinodes: http://drupal.org/node/45475
How I'm creating a custom template for the home page: http://drupal.org/node/52389 (halfway down page, CTRL+F for "Custom Front Page")
--
Thanks
Rich
Comments
A potential solution
Well, I eventually found something that kind of does what I want and since no-one seems to be able to help with this, figured I could at least document my progress on this incase others have the same issue.
The code I found is clearly designed to list flexinodes rather than display one of them by it's identifier, and is actually not working quite correctly ....yet ;-)
Potentially this is because it was written for Drupal 4.6 and I'm running 4.7, but it could just be down to me misinterpreting how this is supposed to function.
I think the code may be Dublin Drupallers - it originated here: http://drupal.org/node/39825
This line here has me a bit baffled as to how to modify it to do exactly what I want, as I'm not great with PHP or the internal workings of Drupal.
This is trying to build a list of flexinodes into an array, whereas what I want is for the code to display only the flexinode I have specified once as I won't have more than one instance of each one.
At present I have two instances of the PHP code above on my home page template, with the variables subtley changed to identify different flexinodes. The first one picks out the correct flexinode, the second on picks out a duplicate of that one as well as the next correct flexinode, which puzzles me as it seems to be ignoring the variable that sets which one it should display!
See code below for my exact modifications:
The second one (faulty):
Insert sound of hand slapping forehead here
Figured it out. Forgot to change the variables in the second instance so they didn't clash with those of the first....duh!
The code of the second instance as it is now:
Of course, this would work much better if it was a function rather than repetitive calls to the database, as to handle the five flexinodes that make up my homepage I'll have to produce five blocks of almost exactly alike code.
I shall maybe have a go at that later, unless someone else can figure it out - I expect it'd be a breeze for a PHP wizard! ^^
Displaying Flexinodes in PHPEngine Template
It was easier than I thought. Please note I'm not a highly skilled PHP guy so I'm not gonna take any responsibility if this breaks your code or install in any way! It may not even be the most efficient means of doing this....
This is specifically designed for situations where you have only one instance of each flexinode. My situation is I have a very complex home page and want several differently styled and contented areas to be controllable via the CMS. There will never be more than one of each panel, so if you try to use this in a situation where you have more than one of a particular flexinode it will probably break spectacularly!
Insert this code at the top of the template file you want to have your flexinodes display in.
And to call up the function to insert a flexinode in your template...
Where the value "flexinode-2" (or whatever) can be found in your nodes table in the drupal database. You can also find it by gong to:
Administer > Content > Content-types
Roll over the 'Edit content type' link for the flexinode you want to embed in the template, and it will show you a number at the end of the URL shown in the status bar of your browser. This number should replace the X in the string 'flexinode-X' and be the result applied to the function call code above.
Hope this helps anyone with a similar problem to me, and hopefully others with a better understanding of PHP and Drupal can expand on this or show how it could be done more cleanly.
As mentioned above, much of the code originated from something I think Dublin Drupaller wrote, so I reckon he should get credit for this, I'd never have managed otherwise :)