Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2021-06-18 10:12:58

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: Image grid always neat

Cunning idea, Destry. Thanks. If the grid is told in CSS to expand the size of the last div to fit the row, that might work.

You’re right it doesn’t display individual ‘your image here’ placeholders, and depending on the grid settings, it can probably be configured flush left anyway (maybe to center the lot requires margin auto on the container?). But I could put a generic, wide ‘your pic here’ placeholder background image in the final div and have it centred so it cropped both of the pointless outer edges as the number of spare slots changes.

Certainly worth thinking about. As it stands, the client is happy with the last row simply centred, regardless of the number of boxes in it. So the padding boxes aren’t needed at the moment, but I would still like to find a solution because it feels like it’s possible.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#14 2021-06-18 10:13:03

etc
Developer
Registered: 2010-11-11
Posts: 5,053
Website GitHub

Re: Image grid always neat

Bloke wrote #330513:

The only thing I’m not sure about is if <txp:images> does a unique, which will filter out the duplicates. If it does, I’m screwed and will have to do it manually!

It does, because sql will retrieve each image only once anyway.

But if you go this way, it’s not too difficult (replace 6 with 12 if you prefer):

<txp:variable name="images">
    <txp:images break="*">
        <txp:image />
        <txp:if_variable name="imgcount" not value>
            <txp:variable name="imgcount" value="6" />
        </txp:if_variable>
        <txp:variable name="imgcount" add="-1" />
    </txp:images>
    <txp:if_variable name="imgcount" value>
        <txp:etc_query data='[1..<txp:variable name="imgcount" />]'>
            *<img src="<txp:site_url />images/placeholder.png" />
        </txp:etc_query>
    </txp:if_variable>
</txp:variable>

<txp:etc_query data="{?images||do_list($|*).@shuffle.implode(|$)}"
    globals="variable" markup="raw"
    wraptag="div" html_id="images" />

Offline

#15 2021-06-18 10:22:13

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,271
Website GitHub

Re: Image grid always neat

Oooh, that’s clever! Thank you. Gonna play with that idea when I get a moment.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

Board footer

Powered by FluxBB