Search

Hello all,

I am looking for some way to upload multiple images to a single entry. I know there are some threads about multiple upload already, but all I read have slightly different goal.

The site I'trying to build is for an architect, so every project's entry shall have at least 5-10 photos. Uploading all to one section is hardly an option, because there will be 20-50 project entries (and growing) with 5-10 photos each... To search for uploaded photo in that mountain of files sounds nasty.

Secondly, I look for an option to create a directory in server via upload field (for example, projects/2013/individual/Johns_house/), so images stay organised on the server as well.

Any possible way to do this?

The way to do it is to have an images section attached to the projects section by a Select Box Link in the images section.

That way, you can use the mass uploader to upload many images in one go, while simultaneously attaching them to a previously created project.

Uploading all to one section is hardly an option, because there will be 20-50 project entries with 5-10 photos each... To search for uploaded photo in that mountain of files sounds nasty.

This is the way it's done in Symphony, and using the Associated Section links in the admin would pre-filter the images section to show only the images attached to the project. It wouldn't really be that much of a mountain ;o)

If you would like some additional help on this, please feel free to ask.

Thanks for helping :) I am very new to this sort of scripting, so everything looks very difficult :D

As you said, I made two sections: "Projects" and "Images". MassUpload works like candy, SelectBoxLink links uploaded images to an entry in section "Projects".

Aaaand stop....

What should be the code to display everything in this manner:


project-title (1) project-info (bla-bla-bla-bla) image-1 image-2 <...> image-N


project-title (2) project-info (bla-bla-bla-bla) image-1 image-2 <...> image-N


<...>


project-title (X) project-info (bla-bla-bla-bla) image-1 image-2 <...> image-N


I can't figure out how to link "image" to "project" in output - images show after all projects...

Hi zarmenas. If you visit a frontend page whilst logged in to Symphony and then append ?debug you'll get the page XML source. If you paste that here (Markdown syntax) or link to a Pastie or something we'll be able to give example XSLT.

This assumes that you've got the data sources set up and applied to your page, of course.

Do you mean in the xslt?

You will need to use xpath to choose the relevant images. Can you post your xml output onto pastie.org or similar and I will give you some pointers.

I am not sure if I use it as it is supposed to, but here's the Pastie thing:

<script src='http://pastie.org/7315860.js'></script>

or: http://pastie.org/pastes/7315860/text

Thanks again guys, I really appreciate the help ;)

I was looking at a lot of CMS and Symphony looks just soooo what I want, just I am completely noob at scripting.

Nope, that's not it. At least not in a usable format :)

Have a good read through the Dev Kits page. You need to enable the Debug Devkit on the Extensions page, and then show us the XML.

What you need to show us should start with <?xml.

<?xml version="1.0" encoding="utf-8" ?> 2013-04-0418:4920130404+03:00Symphony CMSProjektaihttp://192.168.1.4/symphonyhttp://192.168.1.4/symphony/workspaceprojektaiprojektai2/projektai/<![CDATA[?debug=xml]]>http://192.168.1.4/symphony/projektai20971522.3.2zarmenasPBKDF2v1|10000|a62ac4cfcbe56b056f6d|84FRLrjKBalODyFcbVMcP42hzYX0viSmo0DwQTDDQH3QEZwZUZA97g==liveGreetingindexProjektaiImagesPreviewbeute-beispielfoto-gruppe.jpgProjektas-21Mainbelgium.jpgProjektas-22Projektas-1zarmenas-avt1.jpgProjektas-11Projektas-1galvamogeliukas-2resize.jpgProjektas-12ProjektaiProjektas-2

Projektas-2 informacija

info info info info

Projektas-1 informacija

This is the XML you are talking about?

The post looks nothing like the text I pasted... Is this Chrome's bug?

anyway, this is a link to the xml that I pasted to txt document:

https://www.dropbox.com/s/whpl21zx33tg3zm/XML.txt

I hope at least this works :)

That looks like part of it, but you need to use Markdown syntax. Code needs to be indented by four spaces.

I attached the file in txt and html format.

Attachments:
download.xml and XML.txt

Great. Will take a look at this after dinner, and have something in progress.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:key name="image-by-project-id" match="/data/images/entry" use="image-select/item/@id"/>

    <xsl:template match="/data">
        <xsl:apply-templates select="projektas/entry"/>
    </xsl:template>

    <xsl:template match="/data/projektas/entry">

        <article>

            <h2><xsl:value-of select="projektas-title"/></h2>

            <xsl:copy-of select="projektas-info/*"/>

            <xsl:for-each select="key('image-by-project-id', @id)">
                <p><xsl:value-of select="image-title"/>:</p>
                <img src="{$workspace}{image/@path}/{image/filename}" />
            </xsl:for-each>

        </article>

    </xsl:template>

</xsl:stylesheet>

This uses an XSLT key.

xpathr gist here (uses a very slightly modified img src parameter value so that it works in xpathr, outside of Symphony).

Thank you so mutch! I'll try this ASAP

Cheers

-edited- Works like charm. I love it. Thank you again

An alternative is to use the raw power of xPath and abstration:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/data">
        <xsl:apply-templates select="projektas/entry"/>
    </xsl:template>

    <xsl:template match="projektas/entry">

        <article>

            <h2><xsl:value-of select="projektas-title"/></h2>

            <xsl:copy-of select="projektas-info/*"/>

            <xsl:apply-templates select="/data/images/entry[image-select/item/@id = current()/@id]" mode="project-image"/>

        </article>

    </xsl:template>

    <xsl:template match="images/entry" mode="project-image">
        <p><xsl:value-of select="image-title"/>:</p>
        <img src="{$workspace}{image/@path}/{image/filename}" />
    </xsl:template>

</xsl:stylesheet>

I'm all about abstraction ;)

Both methods are both equally as valid.

zarmenas, One thing to bear in mind when choosing a method is that if you have a large data set the key method can be more efficient/quicker as it indexes/creates a lookup table. I also generally find it easier to look at.

Thank you both for this lesson :)

I tried both methods and both work, but to feel the difference there should be a lot of information in the database (at the moment there is nearly no info, so I'll come back to that later).

As I am just a beginner at this, parts of the code in tutorials still look like some voo-doo, but slowly I am starting to see some logic behind everything. Thanks again, guys!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details