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) »
  • Discussion (deprecated) »
  • Alpha and Beta Release Testing »
  • 4.1 Release Testing (Moderator: Kurund Jalmi) »
  • Wordpress - Front end pages appearing within posts
Pages: [1]

Author Topic: Wordpress - Front end pages appearing within posts  (Read 4822 times)

nicol

  • I post occasionally
  • **
  • Posts: 95
  • Karma: 5
  • CiviCRM version: 4.2, 4.3, 4.4
  • CMS version: Joomla 2.5.x, Joomla 3.x Wordpress 3.x, Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.3 / 5.4
Wordpress - Front end pages appearing within posts
December 28, 2011, 02:18:32 pm
The Wordpress installation process worked very well - and faster than my experience with Joomla and Drupal - I also uninstalled and reinstalled easily too. The backend worked without any problem as well :)

The main issue I had is with front-end Civi pages - they all behave as if they are the home page (ie include widgets set to only appear on the front page and appear alongside other posts).

For example, on my testing site, here's:
 - an event page - http://football.micro-major.com/?page=CiviCRM&q=civicrm/event/info&reset=1&id=1
 - a contribution page - http://football.micro-major.com/?page=CiviCRM&q=civicrm/contribute/transact&reset=1&id=1
 - a profile page - http://football.micro-major.com/?page=CiviCRM&q=civicrm/profile/create&gid=1&reset=1
in each it appears that the Civi page is within the top blog post, the second post appears below. The Blogroll links widget is set to only appear on the front page of the site - but it appears on every Civi page too.

Perhaps I am doing something wrong with the URL for each page? Tho it seems to be similar on the demo site.

thanks,

Nic

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: Wordpress - Front end pages appearing within posts
December 28, 2011, 04:40:34 pm

We are working on adding shortcode support for WordPress + CiviCRM (events and contributions only) in a future release. For now, it basically renders as your default blog page. Hopefully this will help with WP frontend

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

nicol

  • I post occasionally
  • **
  • Posts: 95
  • Karma: 5
  • CiviCRM version: 4.2, 4.3, 4.4
  • CMS version: Joomla 2.5.x, Joomla 3.x Wordpress 3.x, Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.3 / 5.4
Re: Wordpress - Front end pages appearing within posts
December 29, 2011, 02:01:16 pm
Thanks. Shortcodes would be great.

I am guessing in the meantime I could use conditional tags (http://codex.wordpress.org/Conditional_Tags) to change the default blog template if it's a Civi-related page. Or use iFrames..

nic

ps - 4.1 looks brilliant.

nicol

  • I post occasionally
  • **
  • Posts: 95
  • Karma: 5
  • CiviCRM version: 4.2, 4.3, 4.4
  • CMS version: Joomla 2.5.x, Joomla 3.x Wordpress 3.x, Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.3 / 5.4
Re: Wordpress - Front end pages appearing within posts
January 04, 2012, 12:39:18 pm
I've been playing further and hit a wall.

I've edited the Main Page Template to hide blog titles and posts and dates and so forth so that a Civi event/contibution page shows only that, but it removes the functionality to have that anywhere else in the site. Conditional tags don't appear to recognize "is_page('CiviCRM')" so I don't see how else to conditionally strip the normal blog title/date/author/etc if it's a CiviCRM page but leave it intact if not.

iFrames aren't really an option because of styling and payment processing - and I might be as well to use a Joo/Pal core if I'm going to hack around that.

Which all leaves me wondering why the front end is using the front page/Main Page Template to include Civi pages, rather than the standalone Page Template?

I'm relatively noobish with Wordpress and am sure there's a good reason, but right now it seems not doing it that way limits using Wordpress and Civi together in a useful way.

I can switch back to Joomla but before I do am wondering if I'm missing something?

Thanks

Nic

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: Wordpress - Front end pages appearing within posts
January 04, 2012, 07:33:30 pm
Quote from: nicol on January 04, 2012, 12:39:18 pm
Which all leaves me wondering why the front end is using the front page/Main Page Template to include Civi pages, rather than the standalone Page Template?

Can you investigate WP code / interface and figure out how you would go about doing this? i.e. use the standalone page template rather than the main template

thanx

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

nicol

  • I post occasionally
  • **
  • Posts: 95
  • Karma: 5
  • CiviCRM version: 4.2, 4.3, 4.4
  • CMS version: Joomla 2.5.x, Joomla 3.x Wordpress 3.x, Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.3 / 5.4
Re: Wordpress - Front end pages appearing within posts
January 04, 2012, 08:07:01 pm
I'll try..

Any pointers to which file(s) in the CiviCRM package control where/how the front-end WP contrib/event/profile pages appear?

Anthony F. Camilleri

  • I post occasionally
  • **
  • Posts: 51
  • Karma: 2
  • CiviCRM version: 4.4.3
  • CMS version: wordpress
  • MySQL version: 5.1
  • PHP version: 4.3
Re: Wordpress - Front end pages appearing within posts
January 05, 2012, 02:57:45 am
I'm not a developer but very keen in solving this issue - I agree, it is making the wordpress plugin close to unusable. I did some digging in the wordpress forums, and found the link in the file I uploaded (I can't post links here for some reason)

Would it be useful?

Anthony

nicol

  • I post occasionally
  • **
  • Posts: 95
  • Karma: 5
  • CiviCRM version: 4.2, 4.3, 4.4
  • CMS version: Joomla 2.5.x, Joomla 3.x Wordpress 3.x, Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.3 / 5.4
Re: Wordpress - Front end pages appearing within posts
January 05, 2012, 05:37:05 am
Unfortunately, I'm not a developer either. My flatmate has written a Wordpress plugins so I was hoping if I could present a slimmed-down problem to him he might have an answer.

Some of the URL building logic for Wordpress seem to be here (the code is well commented)- /civicrm/CRM/Utils/System/WordPress.php - around line 196:

Code: [Select]
       if (! $config->cleanURL ) {
            if ( isset( $path ) ) {
                if ( isset( $query ) ) {
                    return $base . $script .'?page=CiviCRM&q=' . $path . $separator . $query . $fragment;
                } else {
                    return $base . $script .'?page=CiviCRM&q=' . $path . $fragment;
                }
            } else {
                if ( isset( $query ) ) {
                    return $base . $script .'?'. $query . $fragment;
                } else {
                    return $base . $fragment;
                }
            }

I don't know if Wordpress decides how to display the plugin based on the URL that it gets fed (so a URL other than ?page=CiviCRM might be enough to load a different page type automatically) or if what gets loaded on a "?page=CiviCRM" is defined elsewhere and it's that which needs changing.

I can't seem to find the code on the WordPress page you mentioned ( http://wordpress.org/support/topic/how-do-i-create-a-new-page-with-the-plugin-im-building?replies=13#post-1341616 ) re-used here so presume that Civi is using another method - tho without proper coding skills I can't be sure.
« Last Edit: January 05, 2012, 06:27:36 am by nicol »

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: Wordpress - Front end pages appearing within posts
January 05, 2012, 09:59:02 am

I suspect shortcodes will solve most of the issues mentioned in this thread. This will be part of beta2 out next week or so

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

nicol

  • I post occasionally
  • **
  • Posts: 95
  • Karma: 5
  • CiviCRM version: 4.2, 4.3, 4.4
  • CMS version: Joomla 2.5.x, Joomla 3.x Wordpress 3.x, Drupal 7.x
  • MySQL version: 5.x
  • PHP version: 5.3 / 5.4
Re: Wordpress - Front end pages appearing within posts
January 05, 2012, 10:11:38 am
Great :)

Anthony F. Camilleri

  • I post occasionally
  • **
  • Posts: 51
  • Karma: 2
  • CiviCRM version: 4.4.3
  • CMS version: wordpress
  • MySQL version: 5.1
  • PHP version: 4.3
Re: Wordpress - Front end pages appearing within posts
January 08, 2012, 10:44:31 am
First of all @Lobo - thanks for prioritising the shortcode support - this will surely be invaluable.

In the meantime, I have also figured out a workaround to make the civicrm pages use the format I want them to. Assuming you are using 'SEO friendly' permalinks:

- if you type the address as www.blogindex.com?page=CiviCRM then the civicrm page will use the index-page template
- if you type the address as www.blogindex.com/anypage?page=CiviCRM then the civicrm page will use template of anypage

This leads to a possible easy development solution (apart from shortcodes) by which a user could define a default 'parent' page for the CiviCRM as part of installation.

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: Wordpress - Front end pages appearing within posts
January 08, 2012, 12:43:13 pm

considering we are WP newbies, can u please elaborate a bit on how to construct a template for anypage?

thx

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

Anthony F. Camilleri

  • I post occasionally
  • **
  • Posts: 51
  • Karma: 2
  • CiviCRM version: 4.4.3
  • CMS version: wordpress
  • MySQL version: 5.1
  • PHP version: 4.3
Re: Wordpress - Front end pages appearing within posts
January 08, 2012, 02:53:47 pm
Hi Lobo,

I'm hardly an expert, but here goes. Wordpress chooses which template to use for the page based on the following rules:

http://codex.wordpress.org/Template_Hierarchy

Thus, if you were to create www.blogindex.org/page, for most users it would use the page.php which is present in most themes, and revert back to index.php if it didn't exist.

However, if I create a custom-template called anypage.php, it would automatically revert to that template for anypage.

For CiviCRM I have hacked the alpha 1 version to do this the way I need for now, by changing the code in CRM/Utils/System/Wordpress.php from:
Code: [Select]
        if ( is_admin() && !$frontend ) {
            $base .= 'wp-admin/admin.php';
        }
to
Code: [Select]
        if ( is_admin() && !$frontend ) {
            $base .= 'wp-admin/admin.php';
        } else {
            $base .= 'anypage';
        }
This works perfectly, and lets me use whatever template I please (as long as I call it anypage). What would be left to do would be to turn anypage into a user-set variable, where they could enter the page-id or page-slug of anypage, and thus apply the template that is applied to that template.

I should caution that this applies to an installation that is using the 'post name' option from the permalinks settings in wordpress....i have a feeling it would not necessarily work exactly the same under other configurations, although can't be sure since haven't tested it.

Is that helpful?

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: Wordpress - Front end pages appearing within posts
January 08, 2012, 05:52:19 pm

thanx for the response. Gives us a few more things to look at and read up on

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Alpha and Beta Release Testing »
  • 4.1 Release Testing (Moderator: Kurund Jalmi) »
  • Wordpress - Front end pages appearing within posts

This forum was archived on 2017-11-26.