• The page shown provides a sample edition of a magazine to users. It’s a simple page with 16 images with a few buttons, etc mingled in. Right now, this is a static older issue.

    We’re wanting to make this so we show a new issue every fourth week. The magazine is published weekly and we’re already uploading the content for the digital subscribers (as a gallery since there’s no advertising between pages).

    What I’m trying to get to is setting a variable for the desired issue, and using that variable name when selecting each page image from the media library.

    I can’t seem to find anything that really quite does this. I think I could code it all as one big html/php block, but I’d prefer it to be more user maintainable than that.

    Suggestions/ideas?

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    I’m unclear on what sort of user maintenance is involved, or exactly how a variable name would be used to select images. It’d be helpful if you could describe a typical workflow in more detail.

    Thread Starter bbsbcastle

    (@bbsbcastle)

    Right now, I’m playing around with using a code snippet and shortcode to make this work, but that might not be the best way.

    Every week the digital edition has 16 images uploaded with names like “Issue 54-20_001.jpg”, there 54-20 is the issue and 001 is the page.

    My original thought was to have a spot near the top of the page where I could define a variable like $issue=’Issue 54-20′, then where I’m referencing the pages, have the image name defined as $issue . ‘001’ for page 1, etc.

    This is kind of what I’m doing in the code snippet, but it would never be something the end user could maintain that way.

    Just thinking out loud, but maybe I could refine the code snippet shortcode so it passes the page number as a parameter (or the “content”). That way, they could define the page something like…

    [issue]001[/issue]
    [issue]002[/issue]
    [issue]003[/issue]
    [issue]004[/issue]

    Advertising block

    [issue]005[/issue]
    [issue]006[/issue]
    [issue]007[/issue]
    [issue]008[/issue]

    etc…

    Moderator bcworkz

    (@bcworkz)

    Thanks for the explanation, it’s much clearer now. If each issue’s filenames reliably follow a such a rigid structure, then yes, a shortcode like [weekly issue="54-20"] could be made to find related files and generate a page composed of all matched files. Shortcodes are still error prone for novices, the required syntax is exacting. But properly composed, they can do a lot of heavy lifting.

    The handler function can take the string passed as “issue” and use it with glob() to find all files with that pattern in their name. It can then loop through the files returned to generate proper HTML for the page.

    The one thing that might be even better than a shortcode is a custom editor block. Then you could even have separate fields for the 54 and 20. Syntax for passed data is much less exacting than that of shortcodes.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Variable Images in Page’ is closed to new replies.