plumber
Forum Replies Created
-
Forum: Plugins
In reply to: [OS DataHub Maps] Markers as session variables?I came up with something of a workaround that actually serves the logical flow of what I am trying to do. My plugin consumes an API which contains a number of records that themselves contain northing and easting values. I want to select some of those records, show them on a map and then list the details underneath. My original idea was to have a markers shortcode that read the API, converted the northings/eastings to OS GridRefs and wrote a marker file in OSDataHub Maps format. I would also have a notices shortcode that would list out the details. So I would have on a page the following 3 shortcodes:
[markers]
[osmap]
[notices]That was a bit clumsy so I changed the code to call the OSDataHub maps plugin with the correct parameters (ie using do_shortcode) when needed. I found that some record sets didn’t have eastings/northings.
So that allows me to have
[markers]
[notices]The markers one still reads the API but only calls the OSDataHub maps plugin if there’s something to show. I pop the data in a transient so I only need to do an API fetch once .
Its all working fine now. Thanks again for your plugin which makes a hue amount of difference to the look and feel of the site.
Forum: Plugins
In reply to: [OS DataHub Maps] Markers as session variables?Ah – ok, my mistake.
I have persevered with writing to a ftext ile and it seems to work ok. I hadn’t realised there was a wp_upload_bits function that did what I was looking for – and obviously handled the permissions side of things.
I do think a better/neater solution would be to add a filter though as I’m having to check that the file exists, then delete it and then write it. Not a big deal as traffic will always be very light but it’s disk IO I’d prefer to avoid (even if the file is very small). Same thing kind of goes for transients. The API data will not change much so transients make sense but there’s so little traffic that it hardly seems worth it. I will look into it anyway just in case. Thanks again for the plugin. Awesome piece of work
Forum: Plugins
In reply to: [OS DataHub Maps] Markers as session variables?That sounds absolutely perfect! I’ve been toying with writing the data to a text file in wp-content/uploads but that seems fraught with permissions issues and I’m not a good enough coder to handle that without worrying about compromising security. So if you could add a session variable handling capability that would be fantastic.
At the moment, I output the html onto a page using a shortcode function – it’s basically a list of planning application notices – and I’d really like to incorporate a map with markers at the top of the same page. So a session variable sounds like just the job
so presumably I would put something like this in the page?
[osmap markers=”$_SESSION[‘markers’]”]
or assign $_SESSION[‘markers’] to a variable first and use that in the shortcode?
[osmap markers=$mymarkers]
Forum: Plugins
In reply to: Repeat Post or Event for lunch menusFinally coded something myself…
Set up a new database with a single weekdates table holding startdate, enddate and weeknumber. The catering people only change the schedule twice a year so a small admin overhead to stick some new info in every 6 months
Then added a couple of functions to functions.php in my theme (using a modified seashore) – get_this_week and get_next_week which just use basic php date() and strtotime() functions to calculate today’s date and date 7 days from now. Then call the function to read the database to pick up the weeknumber when I’m on the appropriate page.
Also set up some new categories week1, week2 etc (including a week0 for holidays weeks where there’s no menu and week9 as an exception case to handle any unlikely dates that i might have missed) and some posts with the appropriate weekn categories assigned.
Set up 2 empty pages to test – This Week and Next Week.
Once I have that it’s a simple case of using is_page in my page template to determine which page I’m on (This week or next week) and pass the category name that I get from the called get_this_week or get_next_week functions to query_posts.
Job done and works a treat.
Forum: Plugins
In reply to: Repeat Post or Event for lunch menusMenus are the same for each day/week number combination so that every Week1 Monday might be baked potatoes, every Week2 Monday might be toasted sandwiches, every week3 Monday would be pizza and so on. This pattern repeats throughout the year (I think it is changed every few months).
The problem I have is that each day/week number combination relates to a particular day e.g. week1 Monday might be 2 June, 30 June, 21 July, week1 Tuesday would be 3 June, 1 July, 22 July etc.
what I would like to do is show today’s menu i.e. display the menu for 5 June and also display this/next week’s menu i.e. week1 and week 2 listings assuming htis is week1…
What I don’t know is how to pull out these particular pages or posts (or events?) based on the current date.
I could do what you suggest – write 4 week pages with each having 5 daily sub pages – but I am unsure how i could then get one or more of those pages to display on a given date. Thought about maybe using custom fields? Or something like the customised post listings plugin?