Looking for help with my upcoming project (grab data from another block etc.)

Permalink
Hello everyone,

I'm a new face around here, so bear with me since I'm still quite a newbie with concrete5, but I've already grown quite fond with it. So far I've been able to do pretty much everything I have needed to, but now I pretty much ran into a wall with my most recent challenge. I guess it's time to stop hiding and come out forward with my issue.

So I'm starting to build a website for a restaurant. They pretty much require me to do a global area on every page that contains the "today's menu" (located in header). There would be a "Menu"-page on the site that requires a block which they could fill to have a listing for one week at a time.

The global area would need to grab data that's dated as "today" from that 7-day menu block. So there's couple of things I'd like to get tips for:

How to actually pull data from the block that has this current day selected?

Would it be more wise to make one block that contains input for each day or each new day as a new block? I have done some stuff with Designer Content and I'd like to use it with this as well, but do I need to get my hands dirty with some more advanced block-making stuff?

Also one potential problem I see is when the day turns into a new week, that global area would have nothing at all there until they input more stuff to the list, and I can't expect them to do that at nighttime... Would it be wise to have the first day of new week as some sort of reserve, that doesn't show to visitors, but it would still grab data to global area?

So much new stuff in this for me at once, it actually feels a bit overwhelming. I think I once saw some kind of implementation like this done with wordpress, but I would very much like to be able to accomplish this in concrete5, since my clients seem to love the usability of it in general.

I'll appreciate every little tidbit to get me started with this. I made a bad illustrating picture of what I'm aiming for, which I'll attach here as well. Hope you all get the idea from my bad explanation and that image together.

Thanks in advance!

1 Attachment

 
designserve replied on at Permalink Reply
designserve
Hi Tsaos,

And welcome! I've been a member for many years but only recently a participant :) Mainly because I'm a 'learner' at php.

So, I'm sure there are many clever ways to approach this but here's how I would do it. Also please note that I haven't used the addon that I mention here but it has a good reputation.

I would get this calendar addon:

http://www.concrete5.org/marketplace/addons/upcoming-events/...

I would then populate a google calendar with recurring all day events for seven days (the menus). Pull the next event into the header of the site (so that's today's menu displaying until midnight) and pull the next seven days events into the body of the page to display the full menu. At midnight, the next day's menu should appear in the header and the next seven days will change in the body.

It wouldn't have to be midnight, you can play with the time in the site or in google calendar to make it 2am or whatever.

It would take a bit of playing with but this would mean that your client only has to edit a google calendar instead of editing in the site itself and they can edit their menu seven days in advance no problem (or a month in advance if they schedule monthly, or fortnightly, whatever).

An added bonus would be that they could have another google calendar that would list any events being held at the restaurant and you could pull thise in to a different area of the site.

As I said, bear in mind that I haven't used this addon, there are a few calendars out there but I think this sounds like a good, quick, easy way to do what you asked.

Cheers,
Mike
lainej replied on at Permalink Reply
Hi,

Thanks for pointing out that add-on. Seems nifty tool to have, but I actually require the food menu entries to have checkboxes (or dropdown menu) for "gluten-free", "lactose-free" etc. and style them accordingly, and I can't see this doing that function unfortunately.

My mistake though, forgot to mention this on opening post. :(

But at the very least I can see use for that kind of add-on in the future, thanks for making me aware of it!
hutman replied on at Permalink Reply
hutman
One way to accomplish this is to use a true Global Area for this, where they add a block for each day that they want it to display, then use the Schedule Guest Access feature of the block to show/hide it for the time that they want it.

This way they could populate however many blocks they want to in the back end, and they would only show on the day that they are scheduled for. They could add/remove the blocks whenever they want without breaking anything.

Let me know if you have questions about this type of setup.
lainej replied on at Permalink Reply
I'm intrigued about this technique. Is it possible though to make the week long menu list on it's separate page though without the need to make multiple entries about every day?

Also, is it easy to manage? The people I'm making this project to are not tech-savvy at all. That's why I'm aiming for one list and to pull data automatically into global area in the first place actually.
JohntheFish replied on at Permalink Reply
JohntheFish
I would be tempted to try that with another level of indirection just for editing convenience. Set up a page for the daily menus in the Main area using timed permissions along the lines @hutman suggests, then use @mnkras' Global Areas block (or my Universal Content Puller) to pull that pages Main area into the real Global Area.

My reason is that a real Global Area can be a bit fiddly to edit and not convenient for moving blocks. A regular page Main area is easier to edit and manage versions etc.

The result should be pretty much the same thing.
lainej replied on at Permalink Reply
Just gave it a quick spin without permissions for now. I made a "Global Area"-block and a separate page for Menu. Noticed a couple of problems now:

It seems to pull all content from one area to the global area, although I guess the scheduled access is fix for this. However, once on the Menu-page, I get greeted with "You cannot choose area on the same page". I would require it to show at all times on the header, even if you are browsing the Menu-page.

Also, if it pulls the content 1:1 to global area, how can I make a whole week's menu visible on the Menu-page itself, but not on the global area?
JohntheFish replied on at Permalink Reply
JohntheFish
My intent was never that this should be pulling from the official menu page. As you have described, the permissions trick can only work one way or the other, so now you have introduced another requirement, the solution would need to change. My intent was a hidden page for the daily menus, separate to the weekly menus page, that implements the menu with timed permissions as @hutman suggested.

My apologies on the same-page glitch, I had forgotten about that limitation. Considering that the page is not designed to be seen by the public and will be hidden from indexing, you could just ignore that same-page message. If you want to clean it up, you would need a separate page type for the hidden daily menus page that does not have the global area. My UCP block does not pull the content from the same page (a measure to prevent it becoming recursive), but would show nothing.

If you really want all the menu to be in a single location that is shown for the daily menu and today's menu to be pulled to a global area, you will need a more complex solution.

Some possibilities:

1. Have a full week menu as a stack, then pull the entire stack in to the week menu page, and in the hidden page pull each block in turn from the stack into timed permission blocks. Then pull that page area into the header.

2. Have the full week menu as a page with each day given a unique #id. Then pull each day from that into a hidden page as a URL using box grabber (or UCP+box grabber) with a block pulling each day, and give those blocks timed permission and pull the area into the global header.

3. Have the full week menu as a page with each day given a unique #id. Use UCP+box grabber with some Magic Data directly in the header to pull the relevant day (no need for permissions on this one as it is done using Magic Data)

4. Have a page for each daily menu. Summarise them to a weekly menu using a page list + teasers template. Create a custom page list template to show the daily menu in the header. (no need for permissions on this one). You may be able to use Page List Plus to filter on a day attribute and avoid the need for a custom template.

5. Have a page for each daily menu. Summarise them to a weekly menu using a page list + teasers. Use Uber-List + Magic Data +teasers to show the daily menu in the header. (no need for permissions on this one)

If I were doing it, I would use (5), but then I already have all the relevant blocks. If this is a one off and you have not further use for the other addons, (4) is a simple and clean approach that avoids the complexity of timed permissions.
lainej replied on at Permalink Reply
Thanks for all the suggestions. I was experimenting around yesterday and actually made a bit of progress (surprisingly enough) with another type of method, which actually seems to be quite an easy solution usage-wise as well I guess.

So I made couple of entries to Menu-page area as a test. I used Designer Content and basically just made input for date, caption and description at this stage. I added some entries to the area and for the header where the today's menu should be shown, I just made direct connect to the database, hopefully this codesample comes out as intended:

<?php
    $db = Loader::db();
    $rs = $db->query('SELECT * FROM btDCMenu WHERE DATE(`field_1_date_value`) = CURDATE()');
    while($row = $rs->fetchRow()) {
    ?>
    <h2><?php echo $row['field_1_date_value']; ?></h2>
    <p><?php echo $row['field_2_textarea_text']; ?></p>
<?php } ?>


Now it seems to succesfully take in today's menu as intended and I can actually arrange the stuff there a bit differently easily to make it look a bit different than cloned block.

I even think this could work pretty well if I could just solve a little hurdle:

On the menu page, I would need to show visitors this current week menu, starting from monday and ending to sunday. I found this piece of information which could be crucial in achieving this:http://stackoverflow.com/questions/6089960/mysql-query-to-select-da...

If the admin is logged in, it would show every possible entry they have added there. They could even add a year's worth of menu entries in advance to that one area but on the guest side, it would limit which is shown to this current week. I think it would be pretty great management-wise.

So I think in my experimentation I only need to find solution how to actually do the database-query which limits the shown entries to this week on the guest-side and that would be it I guess. This would be easier to do on non-cms ground but this is a bit of an uncharted territory for me now.

If this for some reason is impossible to do, I think I should go around with another solution from your list, but I'd like to see this through first. I have a feeling it's just a tiny obstacle.

Thanks for the suggestions anyhow.