Pergunta

I am trying to create an HTML menu on the fly from a result returned from the Adobe Scene7 Metadata Server. The categories will be based on their folder path property. An example of the data is here:

<asset assetName="company_logo" assetId="1832">
    <fields>
        <field name="s7core.folderpath" value="top/this_project/Logos/"/>
        <field name="s7core.name" value="company_logo"/>
    </fields>
</asset>
<asset assetName="Product_Name_Would_Be_Here" assetId="1896">
    <fields>
        <field name="s7core.folderpath" value="top/this_project/Product Images/Child1/Child2/"/>
        <field name="s7core.name" value="Product_Name_Would_Be_Here"/>
    </fields>
</asset>

I can also get the results in JSON like this:

{
    "status": {
        "code":0,
        "severity":"OK",
        "message":"ok"
    },
    "assets": [
        {
            "assetId":1832,
            "assetName":"company_logo",
            "fields": {
                "s7core.folderpath":"top/this_project/Logos/",
                "s7core.name":"company_logo"
            }
        },
        {
            "assetId":1896,
            "assetName":"Product_Name_Here",
            "fields":{
                "s7core.folderpath":"top/this_project/Product Images/Child1/Child2/",
                "s7core.name":"Product_Name_Here"
            }
        }

In this example, Product Images and Logos would be parent categories, with different children under them. I am just looking to be able to take these results and generate either a menu on the fly, or update a MySQL table with parent/child relationships so I can query and process this.

My final result would be something similar to:

<UL class="parent">
     <LI>Top</LI>
          <UL class="child-1">
               <LI>This Project</LI>
          <UL class="child-2">
               <LI>Logos</LI>
               <LI>Product Images</LI>
          <UL class="child-3">
               <LI>Child 1</LI>
                    <UL class="child-4">
                         <LI>Child 2</LI>
                    </UL>
          </UL>
          </UL>
          </UL>
</UL>

I can import the values all into MySQL and query out the structure from there, I'm just looking for something to parse out the folder paths, delimit by the / marks, and create that hierarchy of lists. The menu will then link into a gallery viewer which will query the server based on the category chosen to find the full results of products that match.

I considered using Magmi to process these categories, as they are in the same format as importing into a Magento installation, but that just seems like overkill to process these categories into a fly-out menu.

Thanks again.

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top