0

I need the user to enter opening hours for their helpline in the CMS along with two sets of text, one that will be displayed if the user views it during their opening hours & another which is displayed outside of their opening hours.

This content needs to be displayed in a modal on specified pages when a link is clicked (a 'modal box' is like a JavaScript overlay on the page).

The way I have been trying to approach the problem (taken from a suggestion else where on Stack Exchange) was to use the Office Hours & Colorbox Node modules together. Unfortunately unless I've misunderstood what Colorbox Node does or how it works I cannot get it to open a modal at all, I can't actually get it to do anything.

Below are the steps I've taken to install the Office Hours & the Colorbox Node modules so hopefully someone can spot what I've done wrong. I am more than open to other suggestions to solve this problem though.

Using the two modules mentioned my plan was to create a custom template which would read the current date & time, compare it to what has been entered into the Office Hours module then display the appropriate text from one of two text area fields in the CMS.

  1. Created fresh Drupal 7 install
  2. Installed Office Hours 7.x-1.4 module (https://www.drupal.org/project/office_hours)

    2a. Installed required module Date api 7.x-2.9 (https://www.drupal.org/project/date)

  3. Installed Colorbox node 7.x-3.5 module (https://www.drupal.org/project/colorbox_node)

    3a. Installed required module colorbox 7.x-2.10 (https://www.drupal.org/project/colorbox)

    3b. Installed required module Libaries 7.x-2.2 (https://www.drupal.org/project/libraries)

  4. Created new content type with the Office Hours field
  5. Created new node setting the new office hours
  6. Created test page with link to office hours page, link has class of "colorbox-node" which should show a modal?

This is what the link tag currently looks like:

<a class="colorbox-node" href="/node/1?width=600&amp;height=600">Test link</a>
  • is there a javascript error ? how does your colorbox-node link look like, does it have width and height specified ? – rémy Dec 6 '15 at 12:37
  • @rémy I've tried the link both with & without the width & height specified without any success. The link now looks like <a class="colorbox-node" href="/node/1?width=600&amp;height=600">Test link</a>. I'll update the question to include it in a moment too. – Neil Nand Dec 6 '15 at 12:42
  • Try looking in the browser dev tool's console to see if there is a JS error when you click the link, and post what you find if something is there. – Alex Finnarn Dec 6 '15 at 23:06
  • @AlexFinnarn I've checked that but noting appears in the console. – Neil Nand Dec 6 '15 at 23:10
  • can you provide a link to the page ? – rémy Dec 7 '15 at 10:17
0

if you run your site under an url like example.com/dat/fresh/site/, remove the first slash in the href, like:

<a class="colorbox-node" href="node/1?width=600&amp;height=600">Test link</a>

or change to full path, like:

<a class="colorbox-node" href="/dat/fresh/site/node/1?width=600&amp;height=600">Test link</a>
  • Answers that are only "guesses" are assumed to be posted as comments. Therefor I recommend to EDIT your answer to remove the guessing part of it. Just a suggestion (to avoid it gets converted to a comment by moderators ....) – Pierre.Vriens Dec 7 '15 at 10:41
  • Thanks for the answer but the site is hosted on a sub-domain, the page that has the link that should open a modal is drupal-test.neilnand.co.uk/node/2 – Neil Nand Dec 8 '15 at 0:21
0

I've managed to work it out, was a very simple problem.

When I installed the colorbox module (not colorbox node) I just installed the module but I need to copy the colorbox plugin into the Drupal libraries directory as well. Soon as I knew found this out and did it, it has started working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.