skip to Main Content

I work at a small cinema in France, and I’m looking for a way to manage a WordPress website.

I want my website to be connected to my cash register software, where I enter all the showtimes for every movie. My software can export this type of XML file: https://cdsdemorc1.cineoffice.fr/TMSexport/cdsdemorc1

In the XML file, each entry corresponds to a showtime. However, on my website, I want all the showtimes for the same movie to appear on the same page.

For exemple, with an xml like this :

<Shows>
  <Show>
    <AuditoriumNumber>1</AuditoriumNumber>
    <ShowStart>2023-07-30T18:45:00+0200</ShowStart>
    <ShowId>2387</ShowId>
    <FilmId>445</FilmId>
    <FilmTitle>Barbie</FilmTitle>
  </Show>

  <Show>
    <AuditoriumNumber>1</AuditoriumNumber>
    <ShowStart>2023-07-30T20:45:00+0200</ShowStart>
    <ShowId>2388</ShowId>
    <FilmId>445</FilmId>
    <FilmTitle>Barbie</FilmTitle>
  </Show>

  <Show>
    <AuditoriumNumber>2</AuditoriumNumber>
    <ShowStart>2023-07-30T14:45:00+0200</ShowStart>
    <ShowId>2389</ShowId>
    <FilmId>444</FilmId>
    <FilmTitle>Elementary</FilmTitle>
  </Show>

  <Show>
    <AuditoriumNumber>2</AuditoriumNumber>
    <ShowStart>2023-07-30T16:45:00+0200</ShowStart>
    <ShowId>2390</ShowId>
    <FilmId> 444</FilmId>
    <FilmTitle> Elementary</FilmTitle>
  </Show>
</Shows>

On the Barbie page, I’d like to display the 2 screenings :

  • 2023-07-30T18:45:00+0200
  • 2023-07-30T20:45:00+0200

On the Elementary page, I’d like to display the 2 screenings :

  • 2023-07-30T14:45:00+0200
  • 2023-07-30T16:45:00+0200

I would like it to be automatic because each week the films and the screenings are different and there is a lot of screenings each week.

I tried with WP All Import plugin and and the ACF Add-on but I did not succeed.

If someone have any idea how to do it so I can try it out?

Thanks for your help!
Best to all.

2

Answers


  1. You can use Powershell. See https://www.cdata.com/kb/tech/wordpress-ado-powershell.rst and code below. You can use Sort-Object, Group-Object, and Export-CSV.

    using assembly System.Xml.Linq
    
    $uri = 'https://cdsdemorc1.cineoffice.fr/TMSexport/cdsdemorc1'
    $doc = [System.Xml.Linq.XDocument]::Load($uri)
    $shows = $doc.Descendants("Show")
    
    $table =  [System.Collections.ArrayList]@()
    
    foreach($show in $shows)
    {
       $auditoriumNumber = $show.Element('AuditoriumNumber').Value
       $showStart = $show.Element('ShowStart').Value
       $showEnd = $show.Element('ShowEnd').Value
       $showId = $show.Element('ShowId').Value
       $filmId = $show.Element('FilmId').Value
       $filmTitle = $show.Element('FilmTitle').Value
    
       $newRow = [psobject]@{
          'Auditorium Number'=$auditoriumNumber
          'Show Start'=$showStart
          'Show End'=$showEnd
          'Show Id'=$showId
          'Film Id'=$filmId
          'Film Title'=$filmTitle
       }
       $table.Add($newRow) | out-null
    }
    $table | Format-Table
    

    Code above creates a hash table. You can convert the hash table to an html table that can be used in wordpress. See following : https://arcanecode.com/2022/03/24/fun-with-powershell-extracting-blog-titles-and-links-from-a-wordpress-blog-with-powershell/

    Login or Signup to reply.
  2. It would probably be easier if you could just combine all repeating data into a single post so you have all dates available in each post (and one post per movie). But it seems WP All Import currently doesn’t support this. I can imagine why this would be tricky for a general purpose import plugin.

    So you will have to add some custom code for this. I can imagine you would create a showtimes custom post-type (but never display these directly). So you can import all showtimes into the database.

    You will also have a custom post-type for movies which can link to multiple showtimes posts. So I think by creating a (PHP) function that will be triggered after an import has finished (pmxi_after_xml_import), the code will do something like this:

    • query all showtimes that are older than the current date and delete these
    • query all movies that have no showtimes (left) and delete or archive these
    • loop through all showtimes and based by the FilmId check if the movie already exist, if yes then just add the showtimes post id to this movie, if not, create new movie post and copy all data from showtime and link it’s id.

    You’ll probably need some custom code to display movie posts which gets the dates from the linked showtimes posts.

    This way you also have old data cleaned up, and maybe you want movie posts not deleted but having an archived status so it won’t show up at a "Now playing"-page but you can still display somewhere else on your site ("Movies not playing anymore") for SEO reasons etc.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search