MonkeyCMS Forum

Go Back   MonkeyCMS Forum > MonkeyCMS > Content Discussion
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1  
Old 11-12-2009, 04:00 PM
harvey harvey is offline
Senior Member
 
Join Date: Jun 2008
Posts: 474
Default Parent, child and sibling relationships - Is this possible?

OK, here's the scenario: I've been asked to develop a new site for Ford Motor Co. (yeah riiiiight!).

I have a definition of 'Car' (Fiesta, Focus, Mondeo etc.).

'Car' is a parent definition of 'Model' (1.2 Popular, 2.0 Sport etc.).

'Model' is a parent definition of 'Colour'. I have populated 'Colour' with Red, Blue, Green, Yellow, Black, White & Silver.

Now I want to display a content page for each 'Model' which will include the colours available. However, a 1.2 Popular is only available in Red, Blue and Yellow, a 2.0 Sport in Red, Blue, Black and Silver etc.

Have I set up my relationships correctly, and if so how do I specify within the content entry for a 'Model' which colours are available, and how would I then display them on a content page?

Is this even possible?
Reply With Quote
  #2  
Old 11-12-2009, 04:25 PM
Colin Colin is offline
Administrator
 
Join Date: Apr 2007
Posts: 1,614
Default

If I was doing it, I wouldn't have the colour as a separate definition, but would instead have it as a content element of Multi-Defined List - then have a list of all of the colours.

This would allow the selection of multiple colours and you can retrieve them with the contentarray function IIRC.
Reply With Quote
  #3  
Old 11-12-2009, 05:59 PM
harvey harvey is offline
Senior Member
 
Join Date: Jun 2008
Posts: 474
Default

Quote:
Originally Posted by Colin View Post
If I was doing it, I wouldn't have the colour as a separate definition, but would instead have it as a content element of Multi-Defined List - then have a list of all of the colours.

This would allow the selection of multiple colours and you can retrieve them with the contentarray function IIRC.
I also want to store a hex value each colour so that I can display a colour swatch for each colour rather than a list, can I do that the way you're suggesting Colin?
Reply With Quote
  #4  
Old 11-12-2009, 06:01 PM
Colin Colin is offline
Administrator
 
Join Date: Apr 2007
Posts: 1,614
Default

I guess I'd have the list pipe separatd:

Red|#ff0000
Blue|#0000ff

etc. Then I'd use some inline PHP to split each element into an array and access it that way. Not ideal though.
Reply With Quote
  #5  
Old 11-12-2009, 06:08 PM
harvey harvey is offline
Senior Member
 
Join Date: Jun 2008
Posts: 474
Default

I thought I'd read on here that you could have multiple parents and that was how I planned set my colours, but I guess a definition can have multiple parents, an item of content can not.
Reply With Quote
  #6  
Old 11-12-2009, 06:10 PM
harvey harvey is offline
Senior Member
 
Join Date: Jun 2008
Posts: 474
Default

Quote:
Originally Posted by Colin View Post
I guess I'd have the list pipe separatd:

Red|#ff0000
Blue|#0000ff

etc. Then I'd use some inline PHP to split each element into an array and access it that way. Not ideal though.
When you say not ideal is that because of the hassle of setting it up or potential performance issues?
Reply With Quote
  #7  
Old 11-12-2009, 06:12 PM
Colin Colin is offline
Administrator
 
Join Date: Apr 2007
Posts: 1,614
Default

Set up - it's a bit messier than it could be, but it'll work and it'd be faster than using definitions.
Reply With Quote
  #8  
Old 11-12-2009, 06:12 PM
Colin Colin is offline
Administrator
 
Join Date: Apr 2007
Posts: 1,614
Default

Quote:
Originally Posted by harvey View Post
I thought I'd read on here that you could have multiple parents and that was how I planned set my colours, but I guess a definition can have multiple parents, an item of content can not.
Nope, it's something I've got on my to-do list but not been implemented yet.
Reply With Quote
  #9  
Old 11-12-2009, 06:20 PM
harvey harvey is offline
Senior Member
 
Join Date: Jun 2008
Posts: 474
Default

Quote:
Originally Posted by Colin View Post
Set up - it's a bit messier than it could be, but it'll work and it'd be faster than using definitions.
OK, thanks very much Colin. I'll have a google and a play, but if you ever get a chance some pointers on the necessary php would be much appreciated.
Reply With Quote
  #10  
Old 11-13-2009, 08:43 AM
harvey harvey is offline
Senior Member
 
Join Date: Jun 2008
Posts: 474
Default

I think I've worked out the necessary inline php, and created a template that is called by ContentArray:

Code:
<div style="width: 100px; height: 100px; float: left; margin-right: 20px;border: 1px solid #000000; background-color: #
%% global $colourtosplit; $colourtosplit = 'red|ff0000'; $splitdata = explode('|', $colourtosplit); addToOutput("$splitdata[1]"); %%
;">
%% global $colourtosplit; $colourtosplit = 'red|ff0000'; $splitdata = explode('|', $colourtosplit); addToOutput("$splitdata[0]"); %%
</div>
I just cant figure out how to replace the 'red|ff0000' i've used for testing purposes with the data pulled from the content.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 03:50 AM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© Poisonous Monkey