Defining Classifieds Global Page

Is it possible to define the blog location of where the Classifieds global page is created?

Rather than have the page automatically displaying on the root blog, we’d like to create a specific blog called ‘Classifieds’ that hosts the page.

thanks

  • member1
    • The Incredible Code Injector

    Thanks James.

    This issue for us is critical for a few of your ‘major’ plugins that command there own exclusive space – if you’re with me?

    For example we’d like to run individual blogs that pull in global content into their own blog for the following plugins:

    MarketPress – global store aggregation. posted about this already here:

    Classifieds

    Membership

    Directory – when its released :wink:. Particularly when/if it allows members to add and display listings from their buddypress profile and then be aggregated to the the Directory blog.

    Global Tags

    and there maybe others…

    We plan to keep our root blog relatively free of content and rather drive traffic directly to other functional area blogs on our site. So having the option to choose where ‘global’ content will reside is an advantage.

    The other option would be to at least be able to nominate one other blog that would contain all other global content (apart from the root), but the preferred option is to create it as above.

    thanks

    Paul

  • Ivan
    • The Incredible Code Injector

    @member1

    If you want to be able to host the classifieds page on a sub-blog you will have to tweak the code a little bit. Here is a guide ( I haven’t tested whether this will work but I assume that it will ) :

    1. Open “classifieds-shortcode.php” and change line 23 ( “$tmp_base_url” ) to match the path relative to your blog classifieds page:

    $tmp_base_url = get_option('siteurl') . '/classifieds/';

    2. Create the “classifieds” page in the above specified blog and put the shortcode ( [classifieds_page] ) in it.

    I can’t guarantee that this will work and whether or not it will introduce new bugs.

  • member1
    • The Incredible Code Injector

    Thanks Ivan.

    I’m running multi-site on subdomains. Can you please update the code above for subdomains instead of sub-directories?

    Also, is this a feature that can be added to the user interface in future releases?

  • member1
    • The Incredible Code Injector

    Thanks Ivan. Apologies for the delay.

    I’ve now tested your solution and can report that after creating one category and one associated product it seems to work well on our Classifieds blog.

    What isn’t working, however, is the widgets.

    Search, Categories and Product Listing widgets all try to resolve to rootblog.com/classifieds/

    The Search and Category widgets both are trying to reach rootblog.comclassifieds/ – i.e. without the forward slash.

    FYI – the code I used in classifieds-shortcode.php is:

    $tmp_base_url = get_option('http://classifieds.mysite.com') . '/classifieds/';

    Any ideas? thanks

  • Ivan
    • The Incredible Code Injector

    @member1

    FYI – the code I used in classifieds-shortcode.php is:

    $tmp_base_url = get_option('http://classifieds.mysite.com') . '/classifieds/';

    There isn’t such thing as “get_option(‘http://classifieds.mysite.com’:wink: “. The $tmp_base_url should point to the URL of your classifieds page.

    The Search and Category widgets both are trying to reach

    rootblog.comclassifieds/

    – i.e. without the forward slash.

    Open classifieds-frontend.php and edit:

    For the search: Line 401 $cf_path = ( is_multisite() ) ? ... $cf_path should point to your “classifieds” page.

    For the categories: Line 425 $cf_path = ( is_multisite() ) ? ... $cf_path should point to your “classifieds” page.

    Maybe there are more places where you need to update the URL path to the new one but I will be able to track them down once you provide me with feedback whether everything is working or they are still links pointing to the incorrect location.

  • member1
    • The Incredible Code Injector

    Thanks Ivan.

    Considering that the URL for my classifieds page is now:

    http://classifieds.mysite.com/classifieds/

    and the ‘root url’ for my classifieds page is:

    http://classifieds.mysite.com (not the root blog for the site….)

    Can you please confirm the correct code to enter into the Search, Categories and Ad Widget areas?

    Search

    function classifieds_frontend_search_form() {

    $cf_path = ( is_multisite() ) ? 'classifieds/' : '/classifieds/'; ?>

    Categories

    <?php $cf_path = ( is_multisite() ) ? 'classifieds/' : '/classifieds/'; ?>

    Ad Widget – couldn’t find this one.

    I tested by putting the full url into the above $cf_path strings but that returned a result still referencing the root blog of the site…. as follows:

    http://mysite.comhttp://classifieds.mysite.com/classifieds

    I’m no coder, but logically, it seems like all instances that reference the ‘classifieds blog’ aren’t complete. Rather than changing the cf_path maybe we just need to find all ways to change how it determines what the root blog for classifieds is.

    Any ideas? thanks a lot for your help.

  • Ivan
    • The Incredible Code Injector

    @member1 So do the following:

    Search

    /* Line 395: */

    $cf_path = 'http://classifieds.mysite.com/classifieds/' ;

    /* Line Line 397: */

    <form method="post" action="<?php echo( $cf_path ); ?>">

    Categories

    /* Line 418: */

    <?php $cf_path = 'http://classifieds.mysite.com/classifieds/' ; ?>

    /* Line 419: Echoes the value of $cf_path in the “href” link attribute */

    href="<?php echo $cf_path; ?>?cat=<?php echo $categories['category_ID']; ?>"

  • member1
    • The Incredible Code Injector

    Thanks Ivan. thats working well now.

    I’m displaying the classifieds – Ads Widget in my sidebar and that is having the same error as above. can you advise how to fix that one?

    Also, I’ve discovered 3 other references to rootblog.com/classifieds within the site:

    Ad Titles & View All Ads link at:

    http://classifieds.mysite.com/wp-admin/admin.php?page=classifieds

    Ad display in the buddypress member profile

    http://community.mysite.com/members/membername/classifieds/

    Almost there :slight_smile: Thanks again for your help.

    Paul

  • Ivan
    • The Incredible Code Injector

    @member1

    I’m displaying the classifieds – Ads Widget in my sidebar and that is having the same error as above. can you advise how to fix that one?

    Open: classifieds-widgets.php and do the following:

    Line 46 and 47:

    href="<?php if ( is_multisite() ... Change the href value of the link within the php tags with:

    echo( $cf_path );

    On Line 41 add the following:

    $cf_path = 'http://classifieds.mysite.com/classifieds/' ;

    Ad Titles & View All Ads link at:

    http://classifieds.mysite.com/wp-admin/admin.php?page=classifieds

    Ad display in the buddypress member profile

    http://community.mysite.com/members/membername/classifieds/

    This is the way it is supposed to be if your $cf_path points to “http://classifieds.mysite.com/classifieds/”

  • Ivan
    • The Incredible Code Injector

    @member1

    Ad display in the buddypress member profile

    http://community.mysite.com/members/membername/classifieds/

    Open “classifieds-buddypress.php” and edit the href tags of the links on lines 51, 52. Do it as described in my previous replay. You can also change the links inside the BuddyPress profile by editing the href tags on lines 65, 68, 72.

    Ad Titles & View All Ads link at:

    http://classifieds.mysite.com/wp-admin/admin.php?page=classifieds

    The file “classifieds-core.php” contains a function called classifieds_page_main_output() Line 492. On line 496 and 498 you can change $classifieds_path. If other links are also pointing to the wrong location you can search for them inside that function and change them accordingly.

  • member1
    • The Incredible Code Injector

    Thanks Ivan.

    Can you advise the correct code for the admin area – via classifieds-core.php if i want to insert http://classifieds.mysite.com/classifieds

    if ( is_multisite() )<br />
    $classifieds_path = 'http://' . $current_site->domain . $current_site->path . CLASSIFIEDS_PATH ;<br />
    else<br />
    $classifieds_path = get_bloginfo('url') . '/' . CLASSIFIEDS_PATH;

    Also, the Buddypress links are changed, but dont direct to the ad itself.

    here’s the link: http://community.mysite.com/members/membername/classifieds/?ad=1

    This could be because we have buddypress set to run on its own blog instead of the root level as is default.

    In wp-config.php: `define( ‘BP_ROOT_BLOG’, 18 );<br />

    `

    Thanks again Ivan

    Paul

  • Ivan
    • The Incredible Code Injector

    @member1

    Can you advise the correct code for the admin area – via classifieds-core.php if i want to insert http://classifieds.mysite.com/classifieds

    $classifieds_path should point to your classifieds URL as described in previous replays.

    As for the BuddyPress, your setup is rather unusual and I don’t think you can integrate the BuddyPress part of the plugin with what you currently have. This will require considerable modifications of the code and I don’t think we can do this via this thread. You can take a look at the Job Board if you need this advanced customization.

  • member1
    • The Incredible Code Injector

    Thanks Ivan,

    I have the admin links all working well now. :slight_smile:

    As for BuddyPress, yes it seems what we are trying to do with it is rather unusual.

    We don’t seem to building our site in the ‘usual’ way, which is causing some occasional headaches.

    We view each function of our site as a separate area rather than piling everything into the root blog. We believe that a plugin and theme for Buddypress shouldn’t take over the whole site. We see it as an important, but not dominant part of what we provide our members.

    Same goes for plugins like MarketPress, Membership, Classifieds etc. There should be an option to select where you want them to reside, give them their own featured area and free up the root blog for other purposes.

    We may have to change our line of thinking if building the ultimate membership site using wpmudev tools in this way becomes too difficult.

    Thanks for your efforts on the Classifieds plugin.

  • johnnymestizo
    • HummingBird

    Hi,

    I am trying to display classifieds listings on my child blog from my main site.

    I want to display classifieds that are within certain category/custom-field.

    I could not make sense of the above, please advise if the updates are included in the current classifieds.

    Thank you

    John

  • Ivan
    • The Incredible Code Injector

    Hi John,

    As of the current version of Classifieds you can’t easily do that. However, If you feel adventures you can use something like that:

    /*
    * Get blog posts from any site on the network.
    *
    * @param int $blog_id ID of the blog.
    * @param string $column The name of the DB column to check against
    * @param string $value The value to check against in the WHERE statement
    * @param string $post_status
    * @return array $posts Array of all the post objects ( Bonus: Each $post object
    * contains $post->blog_id value ).
    */
    function my_get_blog_posts( $blog_id, $column, $value, $post_status = 'publish' ) {
    global $wpdb;

    $key = $blog_id . '-' . $column . '-' . $value;
    $posts = wp_cache_get( $key, 'global-posts' );

    if ( $posts == false ) {
    $posts = $wpdb->get_results( $wpdb->prepare( "
    SELECT * FROM {$wpdb->get_blog_prefix( $blog_id )}posts
    WHERE $column = %s AND post_status = %s", $value, $post_status ), OBJECT_K );

    foreach ( $posts as $post )
    $post->blog_id = $blog_id;

    wp_cache_add( $key, $posts, 'global-posts' );
    }

    return $posts;
    }

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.