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) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Making Civi URLs aliasable
Pages: [1]

Author Topic: Making Civi URLs aliasable  (Read 2516 times)

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Making Civi URLs aliasable
December 24, 2011, 07:07:18 am
Wouldn't it be nice if we could create an alias for public-facing civicrm pages? For example, instead of donating to my org at
http://myorg.org/civicrm/contribute/transact?id=5&reset=1
you could visit http://myorg.org/donate

Currently the barrier to this is the extra args in the url. There may be a good reason for them being there, but I wonder if they are really necessary.

id=5 - does this really need to be a separate arg? Why not just append it to the 'q' string? ID is a pretty common arg, and I suspect that in most if not all cases it would work just fine to assume that the last item in 'q' is id.
So now we have http://myorg.org/civicrm/contribute/transact/5

reset=1 - I have often wondered why this defaults to 0 instead of 1. Virtually every url generated by civicrm contains '&reset=1'. It seems that 1 (aka 'true') is therefore a more sensible default than 'false'. Changing this internal default would eliminate the need for it in most urls.

The end result of these two changes would be a totally aliasable url with no messy php args.
http://myorg.org/civicrm/contribute/transact/5   :D
Try asking your question on the new CiviCRM help site.

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: Making Civi URLs aliasable
December 24, 2011, 08:04:53 am
wouldnt it be better to get civicrm to play better with path alias in drupal? I think it does so nicely in D7 (checked and works) and i remember adding in some "hacks" to ensure it works with D6

so the below url will be more like:

http://myorg.org/donateNow

lobo
« Last Edit: December 24, 2011, 08:08:43 am by Donald 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

robinhood

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 6
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.1.56
  • PHP version: 5.3.5
Re: Making Civi URLs aliasable
December 24, 2011, 08:20:29 am
This appears to be a common request, so it would be awesome if you could solve it.  I am stuck on D6 until some other modules settle down to something better than alpha quality.  So Donald, I dont understand your reply.  What hacks do you apply to make it work in D6??   I never found such a recipe.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Making Civi URLs aliasable
December 24, 2011, 08:21:41 am
Playing nice with path alias means that you have to create "by hand" and remember the urls of the  various campaigns, right?

I think it would be useful if the url generated by default by civi are already the aliased ones. Might simply be a matter of having a hook on crmURL so we can customise them?

I would find it useful even for internal urls as well. My use case is that I communicate to civi mostly via a chat bot, and the urls eg example.org/civicrm/contact/edit?id=42&reset=1 are super long, having something like example.org/civicrm/contact/42 would be nicer.

It would be nice as well for the API to have a real rest interface, eg civicrm/api/{entity}/{id}

For what I've seen, urls on joomla are "not nice", not sure if the option exists or not
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

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: Making Civi URLs aliasable
December 24, 2011, 05:29:17 pm
Quote from: robinhood on December 24, 2011, 08:20:29 am
This appears to be a common request, so it would be awesome if you could solve it.  I am stuck on D6 until some other modules settle down to something better than alpha quality.  So Donald, I dont understand your reply.  What hacks do you apply to make it work in D6??   I never found such a recipe.

You might want to take  look at the D7 version of civicrm.module

http://svn.civicrm.org/civicrm/branches/v4.1/drupal/civicrm.module

and search for:

    // fix the path for the url alias module                                                                                               

and port/copy the code over to D6 and see if that works.

Our current focus / plans involve no more changes to the D6 drupal code (unless its a critical bug fix)

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

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: Making Civi URLs aliasable
December 24, 2011, 06:00:36 pm
Quote from: xavier on December 24, 2011, 08:21:41 am
would find it useful even for internal urls as well. My use case is that I communicate to civi mostly via a chat bot, and the urls eg example.org/civicrm/contact/edit?id=42&reset=1 are super long, having something like example.org/civicrm/contact/42 would be nicer.

I think this might be a good MIH project for 4.2. I suspect its a 40-50 hour project or so and would encompass the following (that i can think of)

1. Get rid of reset=1 in all public facing urls (i.e. add reset=0 to hidden POST / GET to all urls where we need to retain state of the session, which drives a large part of civi)

2. Allow all urls to be of the form:

/civicrm/contribute/transact/id=0/action=live/cs=XXXX/cid=YYY/

i.e. embed the NAME and VALUE as part of the key string

3. If NAME is not present and value is an integer, assume that NAME is id, this allows contribution / event pages to be like:

/civicrm/contribute/transact/5
/civicrm/event/register/12

If there are folks willing to be seed sponsors for this functionality, let us know and we can start an MIH. The above is a rough spec and we'll tweak it based on feedback and better ideas

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

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Making Civi URLs aliasable
December 24, 2011, 09:16:36 pm
This seems unlikely to get picked up as a MIH soon, (there's other, higher priorities afoot). But in case it does, I want to throw one more suggestion into the spec:
As long as we're re-doing how forms are processed, let's take a leaf from the FAPI pages and add a form build ID to the data we're storing. I keep noticing that CiviCRM doesn't work well if I have it open in multiple tabs (and I don't work well when restricted to a single tab) and I suspect the reason is that each form build lacks a unique id, so stored variables are colliding in the $_SESSION storage.
Try asking your question on the new CiviCRM help site.

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: Making Civi URLs aliasable
December 25, 2011, 05:59:27 am

there is a uniq form id which we use to demarcate different forms.

Most forms should work quite nicely in different tabs

there are some forms (specifically there is one pattern where we embed a form within a page) where this does not work. This is fixable, so if u know of any forms that dont work in multiple tabs, let us know and we can potentially fix some/all of them for 4.2

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

robinhood

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 6
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.1.56
  • PHP version: 5.3.5
Re: Making Civi URLs aliasable
December 26, 2011, 05:11:11 am
Quote from: Donald Lobo on December 24, 2011, 05:29:17 pm
You might want to take  look at the D7 version of civicrm.module

http://svn.civicrm.org/civicrm/branches/v4.1/drupal/civicrm.module

and search for:

    // fix the path for the url alias module                                                                                               

and port/copy the code over to D6 and see if that works.

Our current focus / plans involve no more changes to the D6 drupal code (unless its a critical bug fix)
Well, that was easy.  The attached patch adds that code.  Thank you!

And you know that you could make your D6 users happy by deviating from the plan just enough to add this feature to the next 3.4.x.   ;D

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Making Civi URLs aliasable
December 26, 2011, 08:17:00 am
Thanks again Lobo for your help.
I'm glad to hear that progress has already been made on the multiple tab issue. I'll keep an eye out and see if I spot any more instances of it not working.
Try asking your question on the new CiviCRM help site.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Making Civi URLs aliasable
December 27, 2011, 02:50:09 pm
Quote from: robinhood on December 26, 2011, 05:11:11 am

Well, that was easy.  The attached patch adds that code.  Thank you!

And you know that you could make your D6 users happy by deviating from the plan just enough to add this feature to the next 3.4.x.   ;D

Can you create an issue with the patch so it doesn't get lost?

FYI, as of 4.1, the same codebase will work for both D6 & D7.
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Making Civi URLs aliasable

This forum was archived on 2017-11-26.