CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Allowing Users to Search Custom Data
Pages: 1 [2] 3

Author Topic: Allowing Users to Search Custom Data  (Read 10199 times)

Deepak Srivastava

  • Ask me questions
  • ****
  • Posts: 677
  • Karma: 65
Re: Allowing Users to Search Custom Data
May 09, 2008, 04:55:56 am
Quote
I would like to display this search to non-admin users of the website i.e. visitors. and when I attempt to test this I am getting "Accessed Denied errors".

Try granting "access CiviCRM" (only) permission to anonymous user.

Quote
I am also getting the Find Contacts, Advanced Search, Search Builder tabs are still visible.

Here is a simple hack to get rid of those tabs. Add the following code to the file CRM/Core/Menu.php (line-326, inside the method - createLocalTasks )
Code: [Select]
if ( $path == 'civicrm/contact/search/custom' ) {
            return;
}

Quote
Would it be better to approach this via a development of a new module as previously mentioned?

If the custom search you are currently trying to build address your needs, i don't think you need to develop any new module.
« Last Edit: May 09, 2008, 05:14:12 am by Deepak Srivastava »
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

Adam.A

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
Re: Allowing Users to Search Custom Data
May 09, 2008, 10:39:38 pm
Hi,

Thanks Deepak i had set the Drupal configuration correctly but had neglected the CIVI CRM permission settings.

My next issue is:

I would like to return the following fields: Event Description, Event Date, Event Location and the link to the events registration process.

However I can’t seem to find where the lie in the "Entity Relation Diagram" am i supposed to be looking in another location?

-Adam

Deepak Srivastava

  • Ask me questions
  • ****
  • Posts: 677
  • Karma: 65
Re: Allowing Users to Search Custom Data
May 09, 2008, 11:53:48 pm
Event Description => civicrm_event.description
Event Date => civicrm_event.start_date & civicrm_event.end_date
Event Location =>  civicrm_event.loc_block_id (and civicrm_loc_block table will tell you where to get the address / email ..etc from )

These files might be of some help / give some direction :
- api/v2/Event.php
- api/v2/Participant.php
- CRM/Event/Page/ManageEvent.php
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

Adam.A

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
Re: Allowing Users to Search Custom Data
May 14, 2008, 05:58:51 am
Hi,

I have managed to get the Event Description and Event Date working however when it comes to using the civicrm_loc_block table i am having some difficulties.

I have entered the following line to retrieve the event address from the loc_block table as per the civicrm Entity Relation Diagrams

civicrm_event.loc_block_address_id as civicrm_eventLoc,

However it is giving me the following error: Database Error Code: Unknown column 'civicrm_event.loc_block_address' in 'field list', 1054

I think i am reading the Entity Relation Diagram Wrong.

http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+ERD+2.0

How do i find the correct entities to return?

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Allowing Users to Search Custom Data
May 14, 2008, 12:54:14 pm
You need to select civicrm_event.loc_block_id and join to civicrm_loc_block.address_id

Check out phpMyAdmin (a web-based tool for browsing and interacting w/ MySQL DB's) - it should help w/ creating your queries and seeing the tables, columns etc.
Protect your investment in CiviCRM by  becoming a Member!

sonicthoughts

  • Ask me questions
  • ****
  • Posts: 498
  • Karma: 10
Re: Allowing Users to Search Custom Data
May 16, 2008, 01:44:58 pm
were you able to get this to work?  I'd be interested if you could share your experience and code?

Adam.A

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
Re: Allowing Users to Search Custom Data
May 16, 2008, 09:06:07 pm
Hi All,

I have managed to successfully use my phpmyadmin interface to get some of the fields out however i am having some issues locating a few:

1) I am looking for the link for users to register for each event i.e. the "register Now" button. The closest i have found is "civicrm_event.registration_link_text" i have successfully made this return in the results however its is as the name suggests... just the text.

2) Also is it possible to return the event type as text and not as _id value. (event civicrm_event.event_type_id) or do you have to write an if statement to return your event type id's as text.

Yeah i would love to share the this code with everybody, but i would wait for one of the more experienced guys to give it the green light before you give it a go

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Allowing Users to Search Custom Data
May 16, 2008, 11:29:08 pm

1. You can construct the event url, using the event id. The CiviCRM code to do so is:

Code: [Select]
                       $url = CRM_Utils_System::url( 'civicrm/event/register',
                                                      "id={$this->_id}&reset=1",
                                                      true, null, true,
                                                      true );

2. yes you can return the event type as text if you modify the SQL appropriately using LEFT JOIN's etc. If you are not too familiar with SQL, you might want to do it in php

3. please post your code when you think its in a 'ready' state. the community can help you improve it. We do not have a "green light" process :)

lobo

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Adam.A

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
Re: Allowing Users to Search Custom Data
May 18, 2008, 05:57:49 am
Hi again

With regards to construct the event url code, How do i call it up so it returns the URL.

i.e. how do i make it work or where would i be able to find more information on making it work

thanks again for all the support
-Adam

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Allowing Users to Search Custom Data
May 18, 2008, 11:43:56 am

The code is present in my previous message. You need to use that function to get the url. You might want to ask help from someone local who is familiar with PHP and MySQL

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Adam.A

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
Re: Allowing Users to Search Custom Data
May 24, 2008, 08:23:50 pm
Hi All,

I have gotten the code to successfully return results but i am still struggling with returning the URL

The search also seems to be returning the same result 5 times and retuning the "event contact type" instead of "event type"

I have attached the latest version of the code so you can get an idea of what i am talking about. I feel it is pretty close to working but there are a few aforementioned issues that i I am struggling to resolve.

-Adam

Adam.A

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
Re: Allowing Users to Search Custom Data
June 11, 2008, 03:29:02 am
Hi all,

Has anybody had any thoughts on how we can resolve any of these issues?

-Adam

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Allowing Users to Search Custom Data
June 11, 2008, 10:34:31 am
Adam - If you are simply trying to search on / list Events, then you should eliminate all the references to civicrm_participant and civicrm_contribution in the query you're building.

The best approach is to uncomment line 149 when running the search - so it spits out the entire query you are currently using. Then paste that query into phpMyAdmin and tweak it until it gives you the columns and rows you want / expect.

With regard to the "event registration link" - you need to:
* include civicrm_event.id as event_id in your select (you need the ID for each event in your row)
* then add an alterRow() function below the all() function - which will modify your 'civicrm_reglink' column and make it a URL (your can eliminate the 'url' column)
Code: [Select]
// this is untested - but should be close
function alterRow( &$row ) {
        $row['civicrm_reglink'] = '<a href="' .
                                           CRM_Utils_System::url( 'civicrm/event/register', "id={$row['event_id']}&reset=1", true, null, true, true ) .
                                           '">' . $row['civicrm_reglink'] . '</a>';
}

Finally, check out the left join around line 160 in EventAggregate.php to see how to include the Event Type in your query. (test in phpMyAdmin...)
Protect your investment in CiviCRM by  becoming a Member!

Adam.A

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
Re: Allowing Users to Search Custom Data
July 17, 2008, 03:42:25 am
Hi All,

Wow 2300 views...Sorry for lack of activity I have had uni exams

Anyway just a refresher… pretty much what I am currently trying to do is: allow site visitors to search for events based on their starting date and Event Type.
I have been playing around with a my current attempt in phpMyAdmin as suggested by Dave and it has taught me a lot but I have come to realise that my current adaptation of the “events+aggregate+page” search needs pretty much a  do-over.
 The "Find Events" search on the Manage Events Page (Home » CiviCRM » Administer CiviCRM» Manage Events) looks pretty close but I can’t seem to find the file where it is located dose anybody know where it is??

If we can locate that search all we have to do is tweak it so it appears on a stand alone page right?

-Adam

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Allowing Users to Search Custom Data
July 17, 2008, 09:28:34 am
That search form is defined at: CRM/Event/Form/SearchEvent.php which is run from CRM/Event/Page/ManageEvent.php browse() function.
Protect your investment in CiviCRM by  becoming a Member!

Pages: 1 [2] 3
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Allowing Users to Search Custom Data

This forum was archived on 2017-11-26.