0

Welcome! I have a problem with displaying error page when category contacts is clicked. I will briefly describe the situation and circumstances:

  • I wanted to achieve a fully functional contact form with selection of the person you want to write (description of page + dropdown list to chose contact + contact form on a single page). This is achieved by:
    • Each contact (e.g. ContactA, ContactB) is assigned to contact categories (e.g. ContactC);
    • Creating a menu item (e.g. ContactUs) with the type: single contact;
    • Selecting a "default" contact (Select Contact:) ContactA;

The site looks and functions as it should at this stage of development - after selecting a specific contact - sends a letter where it should be sent (still requires overwriting layout, but not the point).

  • When you select (other than default) contact from the dropdown list (ContactB) the page is reloaded - it is necessary to change the recipient.
  • Breadcrumbs changes after reloading by adding extra levels - contact and contact categories (e.g. "HOME->ContactUs" to "HOME->ContactUs->ContactC->ContactB"). Which itself doesn't look bad, but I would avoid this levels.
  • When a curious visitor clicks on ContactC in breadcrumbs - this page reloads and has an address mypage.com/index.php/contactus/10-contactc/3-contactb where numbers are equivalent to ID of the elements;
  • And displays the error message "jos-Error: Contact not found" where error information is in the translation under the label COM_CONTACT_ERROR_CONTACT_NOT_FOUND.

My question is: how to avoid displaying this error? I see three solutions:

  • Writing a php function (e.g. in error.php), which detects occurrence of this specific error and (for example) redirects to the start page - I don't know nor references to use or if "I can".
  • Turning off in breadcrumbs displaying contact categories (checked in global configuration and contact options, but nothing changes on page).
  • Setting in the css specifically for this one link visibility: hidden (or if "I can" php give css class by search for the value of href?).

I've got Joomla 3.4.x and mysql database.

  • Are you using the built in drop down or did you make your own? – Elin Jul 08 '15 at 21:39
  • I use the built-in drop-down - I copied file /components/com_contact/views/contact/tmpl/default.php. There is line `contacts, 'id', 'class="inputbox" onchange="document.location.href = this.value"', 'link', 'name', $this->contact->link);?>`. I overwrite only architecture (more div's and classes) – kopernik_elfka Jul 10 '15 at 10:19

1 Answers1

0

I have achieved this third solution using jQuery. (I know this is not the best, general solution, but it works for me, so it's not THAT stupid in the end.) It looks like this:

jQuery(document).ready(function(){
  //get link by end//
  var contactC = $('a[href$="contactus/10-contactc"]');
  //get parent of link*//
  var contactCParent = contactC.parent(); 
  //add parent of link class//
  contactCParent.attr( "class", "hiddenCat" );
});

and in CSS I have extra lines:

.hiddenCat {
  display: none;
}

Helpful links:

How to get element by href in jquery

jQuery find all elements by part of the id attribute

jQuery attr add id to existing element

jQuery Api - parent()

jQuery Api - attr()

/*/ I had to find a parent, otherwise Joomla displays two span-dividers ("HOME->ContactUs->->ContactB").

Community
  • 1
  • 1