Types&Views displays automatic map when trying to display only individual fields

Home Forums MapPress Support Types&Views displays automatic map when trying to display only individual fields

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #10096
    BradSiegfried
    Participant

    Hi Chris,

    I’ve had good results by integrating MapPress, TurboCSV, and Types&Views on my site.  I’m running into a bit of a snag between MapPress and Types&Views.  I have a single page on which I want to create a mashup of selected custom post types.  I also want to display selected fields from those posts below the mashup.

    The problem is that when I display the desired fields for a post using a Types&Views view template, I also get back the MapPress automatic map associated with the source post.  I want to leave automatic map creation enabled for viewing the source post, but don’t want to get back more than I ask for when I try to extract an individual field from that source post.

    The MapPress table is inserted automatically before any View element.  Below is an excerpt from the displayed page’s HTML:

    <!– wpv-loop-start –>

    <table id=”mapp0_layout” style=”width: 425px; border: 1px solid #000000; “><tr><td><div id=”mapp0_links”></div><div id=”mapp0″ style=”width: 425px; height: 350px; “><span></span></div></td></tr><tr><td><div id=”mapp0_poi_list” style=”width:100%”><span></span></div></td></tr><tr><td><div id=”mapp0_directions” style=”width:100%”><span></span></div></td></tr></table>
    … my desired field output begins here …

    How can I suppress the MapPress table when I want to extract only some particular field out of the source post?  I know this is a gray area between plugins, but I hope you can point me in the right direction.

    Thanks.

    Brad

    #10099
    Chris
    Keymaster

    Hi, I don’t know much about Types & Views, but I can explain that the MapPress automatic map always adds a map to the post content except in two cases:

    1) If there’s already a mappress shortcode on the post/page

    2) The post/page is an excerpt (to determine this, MapPress checks if the standard WP filter for excerpts is active – and it’s probably not used by T&V)

    You could try putting a [mappress] shortcode into the particular post you don’t want automated.  Or you can switch off automatic map display and use shortcodes.

    There’s a function remove_shortcode() in WordPress that can be used to disable a shortcode.  You could add it to your functions.php and use some criteria for the posts where you want to suppress it.

    Finally, the T&V folks might be able to tell you how to disable a specific shortcode in the template, it seems like that might be a common request.

    #10105
    BradSiegfried
    Participant

    Hi Chris,

    I put in a support request with Types & Views regarding this issue (#10096) of filtering the automatic map and  also the issue (#10097) regarding the effect of  mashups on subsequent queries.

    See http://wp-types.com/forums/topic/using-types-and-views-with-mappress-plugin/.

    I’ll let you know what I hear back.

    Brad

    #10107
    BradSiegfried
    Participant

    In mappress.php the function the_content provides several methods to determine whether to add a shortcut that will create an automatic map or not.  Would it be possible to set an appropriate variable prior to or within the View Template so as to match one of the existing methods, thereby not creating an automatic map?

    For example, would it be possible to set the value of $autodisplay or a similar variable at runtime? I’m not clear on how the loop works in terms of when things happen relative to each other.  I’d be happy if I could embed a shortcode to turn auto mapping off and on, for example:

    [maps_off] generate desired output with a View Template [maps_on]

    Or, can you suggest any code additions to the mappress function the_content so that it can determine whether the View Template is asking for the entire post body (automatic map desired) or just a particular field (no automatic map desired)?

    Thanks.

    Brad

    #10110
    Chris
    Keymaster

    Hi,

    I don’t know how to identify the posts you’re using with T&V.  Maybe you can assign them to a particular category or post type.  If you want to use a variable, you can just add something like this to the mappress ‘the_content’ filter:

    if ($myvar == true)
    	return;

    Or, you can add your own filter to remove the MapPress ‘the_content’ filter.  For example, if you want to always suppress MapPress when the post type = ‘mytype’ add this to functions.php:

    function myfunc() {  
    	global $post, $mappress;  
    	if ($post->post_type == 'mytype')   
    		remove_filter('the_content', array($mappress, 'the_content'), 2); 
    } 
    
    add_filter('the_content', 'myfunc', 1);
    #10231
    BradSiegfried
    Participant

    Hi Chris,

    Between my content changes and your latest code changes, I’m not having an issue with unwanted automatic maps any longer.  If it crops up again I’ll try using the filter as you suggested.

    Please consider this issue resolved.

    Brad

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.