Drop downs

I'm having a little trouble with templates.


I've designed a template where I have a table to which everything is entered into (surprise surprise)



Think of the page as an umbrella (T shape)



Top is a banner, left is part of the template, right is for the div that can be edited.



Okay, in the left part, I want to put a drop down menu that's driven by mysql.



So, I've got a php file that calls an existing mysql database I have to grab data which is parsed through javascripting to publish some dropdown menus



works when i load it in a browser as a .php file.



i'm not sure as to how to embed the code into the template. the parse file for the template is simple html. Is it possible to embed it and still have the php script run?

You cant embed PHP into the design parse file or standard content with Matrix.


Typically, we would create a design area to print the drop-down. This allows you to write your own PHP code and basically print whatever you want. There are no docs for building a design area, so if you wanted to give this a try you'll probably have to use the copy-paste method of development :slight_smile:

D'oh!!


Though, i'm not sure what you mean by "the copy-paste method of development."



Got any links or references to similar cases/pages that I can look at?

[quote]Got any links or references to similar cases/pages that I can look at?
[right][post=“6488”]<{POST_SNAPBACK}>[/post][/right][/quote]



That’s what we mean about copy-paste development. You’ll have to copy & paste the existing Design Area code to try and make your own.



Though, I’m curious to know why you’d want a MySQL database creating the menu instead of using Matrix’s own menu system.

The reason why is because the MySQL database I'm using is an existing database that contains information that I want to populate.


For example (if mysource matrix can do this… then I'd really like to know how)



[car manufacturer ^] [go]

[model ^][broucher][specsheet]



(where [ name ^ ] = Drop down menu)





So, lets say I selected Porsche from the car manufacturer menu. The Go button then gives me an option to go to the catalogue page where all porsche models are layed out.



But if I didn't want to hit the go button, then the Model dropdown menu allows me to choose the model I want. After I've selected the model, if I click the broucher button, I get to view a page that has all the highlights, images etc. If I click the specsheet, I get a table of specifications.



So basically, the existing database has

Manufacturer [brand1, brand2, brand3, brand4 … brand n]

BrandX [model1, model2, model3, model4 … model n]

Modelx [(url1, url2)1, (url1, url2)2, … (url1, url2)n]



The database is actually used for an existing system and stores more than just URL's, but that's the only proportion of it I need to generate the dropdown menus.



If there's a simpler way where by I can use the Asset ID's, i'm all ears.

Alternatively, if you know of a way to generate a dropdown from the following Tree structure in mysquizz, that would also be useful…


Site

|Manufacturer <-- First dropdown box

| | Toyota <-- catalog will default to this asset

| | | Corolla <-- broucher will default to this asset, also a value in 2nd drop down box.

| | | | Specsheet

| | | Rav4

| | | | Specsheet

| | Mazda

| | | 323

| | | | Specsheet

| | | 626

| | | | Specsheet

| | Porsche

| | | Boxter

| | | | Specsheet



ETC

Hmmm… interesting. You would be able to auto-build those drop-downs in v3.6 with the new Listing Engine (if you have access to the Commercial CMS module). It would be tough to do dynamically in v3.4 or without the CMS modules.

Hmm, no, I can't actually afford any of the modules. So i'm going as open source as I can without paying for anything. (sorry if that sounds a little scummy, but I'm a struggling student who's getting by with what I can)


If I can't do it dynamically, I can resort to a static set… massive, annoying, but functional… I just thought the standard packages had something that did it or something.



Though, if you have any ideas or know of any ways, I'm open to suggestions. I am surprised no one has asked about it before, I would have thought it be a common thing…

[quote]Hmm, no, I can’t actually afford any of the modules. So i’m going as open source as I can without paying for anything. (sorry if that sounds a little scummy, but I’m a struggling student who’s getting by with what I can)
[right][post=“6498”]<{POST_SNAPBACK}>[/post][/right][/quote]



No, that’s perfectly understandable. :slight_smile: I’m thinking now that you could probably do this with just the built-in menu code that ships with Matrix (assuming you create a site structure to support it, ie. first level of pages = manufacturers, then models under those, etc).



Can you post the HTML output (edited if necessary) that produces the drop-downs for you now?

<!-- Manufacture Drop down list //–>
<form name="Man">

<select name="manufacture" size="1" WIDTH="115" STYLE="width: 115px" onchange="UpdateHand(), UpdateDevice()" style='border:1px double #666666; cursor:hand; background:#E2E1E5; color: #333333; font-style:normal; font-variant:normal; font-weight:normal; font-size:8pt; font-family:Arial'>

<option value = "none" style="font-family: Arial; font-size: 8pt;">Select Manufacturer</option>

</select>

<input type="button" style='border:1px double #666666; cursor:hand; background:#E2E1E5; color: #333333; font-style:normal; font-variant:normal; font-weight:normal; font-size:8pt; font-family:Arial'

onclick="manufGo()"

value="Go">

</form>



<!-- Model Drop down list //–>

<form name="Model">

<select name="model" size="1" WIDTH="115" STYLE="width: 115px" onchange="UpdateDevice()" style='border:1px double #666666; cursor:hand; background:#E2E1E5; color: #333333; font-style:normal; font-variant:normal; font-weight:normal; font-size:8pt; font-family:Arial'>

<option value = "none" style="font-family: Arial; font-size: 8pt;">Select Model</option>

</select>

<input type="button" style='border:1px double #666666; cursor:hand; background:#E2E1E5; color: #333333; font-style:normal; font-variant:normal; font-weight:normal; font-size:8pt; font-family:Arial'

onclick="Model()"

value="Broucher"><input type="button" style='border:1px double #666666; cursor:hand; background:#E2E1E5; color: #333333; font-style:normal; font-variant:normal; font-weight:normal; font-size:8pt; font-family:Arial'

onclick="Spec()"

value="Specifications">

</form>





<HR>

Manufacturer's Website:





<!-- Manufacturer Web Drop down list //–>

<form name="ManWeb">

<select name="manuf_web" sizes="1" WIDTH="115" STYLE="width: 115px" style='border:1px double #666666; cursor:hand; background:#E2E1E5; color: #333333; font-style:normal; font-variant:normal; font-weight:normal; font-size:8pt; font-family:Arial'>

<option value = "none" style="font-family: Arial; font-size: 8pt;">Select Manufacturer</option>

</select>

<input type="button" style='border:1px double #666666; cursor:hand; background:#E2E1E5; color: #333333; font-style:normal; font-variant:normal; font-weight:normal; font-size:8pt; font-family:Arial'

onclick="manufWeb()"

value="Go">

</form>



That's it… without the java scripting of course.

You could replicate this quite easily using the Matrix menu system. Basically you would structure your site heirarchy in the backend as:


Site

| Toyota

| | Corolla

| | | Web URL #1 (redirect asset)

| | | Web URL #2

| Mazda

| | 323

| | | Web URL #1

| | | Web URL #2



On the front end you would build your design areas like this to generate your dropdown:


    
    
     Select Manufacturer
    
    
    
    
    
    
    
     
    


Then for each drop down set the level (and change the mysource asset id_name tags to something unique):

<MySource_SET name="level" value="1"/> <!-- This would be your model -->
<MySource_SET name="level" value="2"/> <!-- This would be your web url -->

I'm not sure how your javascript works, but I'm assuming the need to navigate to a URL.

This kind of menu system will change the contents of the select boxes depending on where in the hierarchy you are (as you visit each page of course). If you want a system that generates select boxes that contain all sub items [b]all[/b] the time then it gets a little bit trickier, but it is possible.

Sorry to bring up an old topic. But are you saying there is no way to embed a php script into matrix? If now, what can I do if I want to write something custom, and have it work in matrix?

[quote]Sorry to bring up an old topic.  But are you saying there is no way to embed a php script into matrix?  If now, what can I do if I want to write something custom, and have it work in matrix?
[right][post=“11051”]<{POST_SNAPBACK}>[/post][/right][/quote]



I answered this in the other topic, but essentially you cannot embed PHP into any of the content areas of Matrix (i.e. the WYSIWYG or Raw HTML containers). In order to write custom code, you need to create a custom asset for Matrix.