Flashblocks Flash CMS
Welcome, Guest
Please Login or Register.    Lost Password?
Re:Nested templated menus (1 viewing) (1) Guests
Go to bottom Post Reply Favoured: 0
TOPIC: Re:Nested templated menus
#4578
vlax ()
User Offline Click here to see the profile of this user

 
Nested templated menus 6 Months, 4 Weeks ago
Hi,

I have a templated site with a main navigation that's working great now, but I came to the point when I want to add a sub menu inside one of the templates.
The problem I see now is that I don't want to let the user have to pick an xml file for each submenu in each instance of the template but instead have the submenu generate the file from a default file with basic items and save it automaticaly with a name formed by container_mc_name + template_instance_name + submenu_name.

Is that possible? It's already previwed on the design or is there some code tweaking that would permit this?

Best Regards

Vlad
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4583
admin ()
User Online Now Click here to see the profile of this user
Flashblocks Birthdate: 2005-02-14
 
Re:Nested templated menus 6 Months, 4 Weeks ago
The file name is managed by Flashblocks but you can hard code the name or perhaps only hard code the name if the file name is not found in the data file. Open then menu movie clip and look at line 47:
Code: :

 var file obj.data.selectFile[0].src


And then perhaps add a line after this - something like:
Code: :

 if (!filefile "file.xml" // or perhaps some algorithm to generate your file name.

 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4584
vlax ()
User Offline Click here to see the profile of this user

 
Re:Nested templated menus 6 Months, 4 Weeks ago
Hi I took a slightily more complex approach here is the code:

Code: :

 if (file) {         //    set editor tags from here rather then from editblock component inspector.         obj.target.editblockHeader file         loadMenu(file)     } else {             // Loads the default XML for subitems     var submenu:XML = new XML();     submenu.ignoreWhite true;     submenu.onLoad = function(success) {                  flashblocks.Flashblocks.SaveFile("flashblocks/data/USICdataFiles_template/" obj.target.editblockID ".xml"submenunull, {fbobj.target.editblockIDsaveSSflashblocks.Flashblocks.localhost flashblocks.Flashblocks.Config.paths.saveSSbackupPathflashblocks.Flashblocks.Config.paths.tempDir "save."});         loadMenu("flashblocks/data/USICdataFiles_template/" obj.target.editblockID ".xml");          };     submenu.load("flashblocks/data/USICdataFiles_template/defaultsubmenu.xml");                       }



what i'm trying to figure out first is how to make this less complex :-) and second how to get the path where the templates are being stored without hardcoding it.

Your help is much apreciated!

Vlad
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4588
vlax ()
User Offline Click here to see the profile of this user

 
Re:Nested templated menus 6 Months, 4 Weeks ago
Another drawback of this method is that when you want to go and edit file with the XML editor there's nothing associated to the Menu :-(
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4590
admin ()
User Online Now Click here to see the profile of this user
Flashblocks Birthdate: 2005-02-14
 
Re:Nested templated menus 6 Months, 4 Weeks ago
Have you considered my example above?
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4608
vlax ()
User Offline Click here to see the profile of this user

 
Re:Nested templated menus 6 Months, 3 Weeks ago
if (!file) file = "file.xml" // or perhaps some algorithm to generate your file name.

Hi sorry I was too fast to answer but I'm trying your solution and in fact using an algorithm to generate my file name.
That's because I want every submenu to be independent to have a diferent quantity of items in it.
Now the problem is your code wont generate an inexistent file, the file must exist beforehand :-(
Here my code:

Code: :

 var file obj.data.selectFile[0].src;     if (!filefile "flashblocks/data/USICdataFiles_template/" obj.target.editblockID ".xml"

 
Report to moderator   Logged Logged  
 
Last Edit: 2008/05/13 09:29 By vlax.
  The administrator has disabled public write access.
#4619
admin ()
User Online Now Click here to see the profile of this user
Flashblocks Birthdate: 2005-02-14
 
Re:Nested templated menus 6 Months, 3 Weeks ago
I suppose you could write an onLoadError function that would be called if a gallery xml file could not be loaded at which point you could use the flashblocks.Flashblocks.SaveFile function to create the file.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4622
vlax ()
User Offline Click here to see the profile of this user

 
Re:Nested templated menus 6 Months, 3 Weeks ago
I tried that but onLoadError is not Firing :-(
Any ideas?

Code: :

 function loadMenu (file) {          if (flashblocks.Flashblocks.httpfile += "?="+Math.random()     loaded=false;     xmlObj = {}     xmlObj Flashblocks.XmlToObj()     xmlObj.arrays true     xmlObj.toOBJ xmlObj     xmlObj.ignoreFirstChild true     //xmlObj.nodeTag = "txt"     xmlObj.addEventListener("onLoad"this);     xmlObj.addEventListener("onLoadError"this);     xmlObj.loadXML (file) } function onLoadError (evt) {                 // Loads the default XML for subitems     var submenu:XML = new XML();     submenu.ignoreWhite true;     submenu.onLoad = function(success) {                  flashblocks.Flashblocks.SaveFile("flashblocks/data/USICdataFiles_template/" obj.target.editblockID ".xml"submenunull, {fbobj.target.editblockIDsaveSSflashblocks.Flashblocks.localhost flashblocks.Flashblocks.Config.paths.saveSSbackupPathflashblocks.Flashblocks.Config.paths.tempDir "save."});         loadMenu("flashblocks/data/USICdataFiles_template/" obj.target.editblockID ".xml");          };     submenu.load("flashblocks/data/USICdataFiles_template/defaultsubmenu.xml");      }



Regards
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#4627
admin ()
User Online Now Click here to see the profile of this user
Flashblocks Birthdate: 2005-02-14
 
Re:Nested templated menus 6 Months, 3 Weeks ago
Sorry, actually the error is retrieved in the onLoad function. Check the status of evt.success.
Code: :

 function onLoad (evt) {     if (evt.success) {         current code...     }     else {         create file...     } }

 
Report to moderator   Logged Logged  
 
Last Edit: 2008/05/14 20:45 By admin.
  The administrator has disabled public write access.
#4632
vlax ()
User Offline Click here to see the profile of this user

 
Re:Nested templated menus 6 Months, 3 Weeks ago
Thanks I will try that
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
Go to top Post Reply
get the latest posts directly to your desktop

Thank you