Forum Replies Created

Viewing 15 replies - 1 through 15 (of 34 total)
  • Thread Starter antonlargiader

    (@antonlargiader)

    What I mean was that I wanted the body text of the event to be in HTML paragraph format, <p> tags, etc. However, I couldn’t format it as Paragraph using the HTML editor because Paragraph was already in effect. I could select text, and try to apply Paragraph format to it, but Paragraph was already ‘on’, check mark on the drop-down format list, etc… but <p> tags were not present in the output. I could find no way to get the editor to add <p> codes to the text.

    I’ll work on it a bit more.

    Thread Starter antonlargiader

    (@antonlargiader)

    Wrap-up from my end: for me, it works as long as I don’t use excerpts. My final solution was to use the_content or get_the_content with global $more = 0 before I displayed the excerpts, and $more = 1 when I displayed the full posts. So basically I had to work around a lot of stuff that WP wants to do automatically. Again, a self-created problem because I’m not [yet] making it a full WP site.

    Thread Starter antonlargiader

    (@antonlargiader)

    Just to clarify here, it does eliminate the default More link if I actually use the More breaker in the post. But if I use the excerpt functions instead, I get both. So it’s just the excerpt stuff that doesn’t work for me.

    Reading the text on the last checkbox, it sounds like this is normal behavior? It only works on the titles, not on the text itself? That’s what it seems to say, but I guess I didn’t fully understand that. Seems odd to want to have More links in a title in the first place.

    Thread Starter antonlargiader

    (@antonlargiader)

    At the moment it is set to WP default, under Settings >Permalink Settings. I had something in the Category Base field, but removed it.

    The test page is at https://www.cvillecameraclub.org/test.php if you want to see it.

    EDIT: BTW I do have the last checkbox checked, for using CMLC with excerpts.

    EDIT2: My CMLC permalink setting is for a static link, but you can see that on the page.

    Thread Starter antonlargiader

    (@antonlargiader)

    Arrgh. The developer has not posted anywhere in nearly half a year… I’m thinking that I put time into an abandoned plug-in.

    TEC is the topmost of the panels and when I roll it up the following ones behave normally as far as not overlapping the categories box.

    However, I also am unable to rearrange the panels.

    Thread Starter antonlargiader

    (@antonlargiader)

    We have a measure of success. I won’t be able to do any more work on this until next week so I’ll post what I have and let the community take over. Hint, hint.

    It turns out the best thing to do was to get TEC to write the meta string that PGM wants. That way all of the information is processed at the same time, in the same place, where all of the variables reliably exist. It updates the array string every time the post is edited.

    This bypasses the PGM address adding interface. If you try to add addresses in the PGM section of the post editor I have no idea what will happen. If you find out, tell me. Otherwise, don’t use that section at all.

    Here’s what you can do to get category-wide event maps with The Events Calendar:

    Install the Post Google Map plug-in and become familiar with it.

    Edit the-events-calendar.php and find public function addEventMeta.
    Scroll down about 30 lines and you’ll find:

    //update meta fields
    foreach ( $this->metaTags as $tag ) {
    ???$htmlElement = ltrim( $tag, '_' );
       if ( isset( $_POST[$htmlElement] ) ) {
          update_post_meta( $postId, $tag, $_POST[$htmlElement] );
          }
       }

    Add the following code at that point:

    // begin Anton's crude hacks
    $gmp_long = '';
    $gmp_lat = '';
    $gmp_address1 = $_POST[EventAddress];
    $gmp_address2 = '';
    $gmp_city = $_POST[EventCity];
    $gmp_state = $_POST[EventState];
    $gmp_zip = $_POST[EventZip];
    $gmp_marker = 'purple.png';
    $gmp_title = '';
    $gmp_description = '';
    $gmp_desc_show = false;
    //get long & lat BRM
    if (isset($gmp_long) && !empty($gmp_long) && isset($gmp_lat) && !empty($gmp_lat)) {
    ???}
    elseif (isset($gmp_zip) && !empty($gmp_zip)){
       $options_arr = get_option('gmp_params');
       $key = $options_arr["post_gmp_params"];
       $addressarr = array($gmp_address1, $gmp_city, $gmp_state, $gmp_zip);
       $address = IMPLODE(",", $addressarr);
       $iaddress = "https://maps.google.com/maps/geo?q=".urlencode($address)."&output=csv&key=".$key."";
       //use the WordPress HTTP API to call the Google Maps API and get coordinates
       $csv = wp_remote_get($iaddress);
       $csv = $csv["body"];
       $csvSplit = split(",", $csv);
       $status = $csvSplit[0];
       $lat = $csvSplit[2];
       $lng = $csvSplit[3];
       if (strcmp($status, "200") == 0){
          // successful
          $lat = $csvSplit[2];
          $lng = $csvSplit[3];
          }
       $gmp_long=$lat;
       $gmp_lat=$lng;
       }
    //create an array from the post data and long/lat from Google
    $gmp_arr=array(
       "gmp_long"=>$gmp_long,
       "gmp_lat"=>$gmp_lat,
       "gmp_address1"=>$gmp_address1,
       "gmp_address2"=>$gmp_address2,
       "gmp_city"=>$gmp_city,
       "gmp_state"=>$gmp_state,
       "gmp_zip"=>$gmp_zip,
       "gmp_marker"=>$gmp_marker,
       "gmp_title"=>$gmp_title,
       "gmp_description"=>$gmp_description,
       "gmp_desc_show"=>$gmp_desc_show	);
    //save address array as option gmp_arr
    update_post_meta($postId, 'gmp_arr', $gmp_arr);
    // end Anton's crude hacks

    This is crudely done and you’ll see (once you look at the code in PGM) that a lot of things are hard-coded that should be options. That can come later but as I said, I’m out of time for now.

    The easiest way to see this in action is to add the sidebar widget for Post Google Maps.

    BTW you are at the mercy of Google Maps as to the accuracy of the points. One of mine is showing up at 0,0 lat/long. For those cases you can probably add the lat/long into the PGM section and find a way to not overwrite it with the code I listed above. Or edit the array string manually if you’re brave.

    BTW2, this is probably US-specific for now. Not sure.

    Feedback please! Without it nothing improves.

    Thread Starter antonlargiader

    (@antonlargiader)

    I think I know how it’ll work, but I’m restructuring a few things in PGM. Specifically, I’m trying to get it to read the postmeta fields whenever the post is saved, and rewrite the array string. It’s just difficult since I really don’t know what I’m doing. For some reason I’m having a very hard time getting it to know what the post ID is. However, I have actually had it work when something else didn’t work, so I’m making progress. ??

    It’s actually not really important for now if the edit box even appears, since all of the important data comes from the postmeta table rather than from user input. I just want a certain action (read the postmeta and write the string) to happen at a certain time. There’s a hook for it but it’s not working out yet.

    Thread Starter antonlargiader

    (@antonlargiader)

    Another difference is in the way they process the address information.

    PGM uses its own form. When an address is added, the page refreshes and the address info is now in the $_POST array. It gets read from there and written to the database as the array string.

    TEC seems to use WP functions to save the values and retrieves them with get_post_meta so they are in the fields when you edit the post.

    In order to have this work in a single edit session, PGM needs to see those values when the page refreshes so it can create the array string and write it to the post meta table. So the question becomes, where is the best place to grab those values. The best (from an integration standpoint) is probably to use get_post_meta but I have to be sure the values are already there. I don’t know if they will be in the $_POST array or not, since there isn’t a form for the TEC information.

    Thread Starter antonlargiader

    (@antonlargiader)

    Reading a bit more. I’m beginning to understand plug-ins a bit.

    A fundamental difference between PGM and TEC is that PGM maps multiple points for a single post and TEC maps one. This essentially explains the difference in how the data is stored; the PGM string gmp_arr is simply an array string containing the same sort of thing that the individual fields of TEC contain. However, you can have several such array strings in PGM. When the WP function get_post_meta is called to find the gmp_arr values for a particular post, it can come back as a string or as an array of such strings.

    For my purposes, one location per post makes sense. So a quick solution would be to:
    1) change PGM’s add_post_meta functions to update_post_meta, which would ensure that only one address was stored
    2) have PGM look at TEC fields for that data, rather than its own
    3) make PGM update every time the post is edited, rather than just when its own ‘add address’ button is hit.

    It’s a dirty solution because the same data is stored twice, but tighter integration means more work and I’m not really skilled enough for that. But as I go along I’ll probably get more familiar with these two bits of code.

    Comments?

    I think that’s all a matter of your theme. If you switch to the default theme, do you see the big calendar?

    Thread Starter antonlargiader

    (@antonlargiader)

    A few more notes for those looking at the code for PGM (in this case post-google-map.php):

    Around line 254 the contents of the $_POST array are read. This only applies if new addresses are added. If this were changed to read the fields from TEC (probably not too hard to change) a new address string would be created every time the post was edited, which would be OK if the old one were deleted. One or two more fields would have to be added for marker type, etc.

    For all other purposes, PGM reads the $gmp_arr string (looks like what I cited previously) and uses that.

    So one really crude way to make this work would be to add ‘marker type’ to the TEC form, and then every time the post is edited PGM will delete the old $gmp_arr value and create a new one from the TEC address fields.

    A slight complication is that addresses are added within the PGM section with its own submit button, while TEC updates using the page’s Update button.

    Hey, someone start writing some code!! ??

    Thread Starter antonlargiader

    (@antonlargiader)

    Read the third post again. It describes the general logic of what I did. If you don’t have similar code for line 60 then look around a bit. For me, it was line 60. The line you cite is line 24 for me. Maybe you have a lot of word wrapping going on. Maybe we’re using different versions of the code.

    This line controls the presence of the address block on the display. If you really don’t understand the php code you might not be able to get anywhere. In that case, hopefully a new release will come out soon with a similar modification.

    Thread Starter antonlargiader

    (@antonlargiader)

    No problem. Until someone tells me to shut up I’ll keep at it. ?? I did look at it a bit more. Some of this will be old news for developers but it’s new news to me so I’m writing everything down.

    Add-on information is stored in a table called postmeta. If you look at that table you’ll see the add-on fields for TEC and for other plug-ins. There’s a big difference in how the two plug-ins (TEC and PGM) store their custom info.

    TEC stores individual fields such as _EventAddress and _EventCity. This way when the post is edited these fields can be pulled up and TEC repopulates the post edit form.

    PGM builds the address and other info into a string and stores that, for example:

    a:11:{s:8:"gmp_long";s:0:"";s:7:"gmp_lat";s:0:"";s:12:"gmp_address1";
    s:0:"";s:12:"gmp_address2";s:0:"";s:8:"gmp_city";s:12:"Buck Meadows";
    s:9:"gmp_state";s:2:"CA";s:7:"gmp_zip";s:5:"95311";s:10:"gmp_marker";
    s:10:"purple.png";s:9:"gmp_title";s:0:"";s:15:"gmp_description";s:0:"";
    s:13:"gmp_desc_show";s:2:"on";}

    A weakness of PGM is that you can’t edit the address. When you edit the post, the fields are pulled out of this string and displayed but you can’t edit them. You have to delete the address and make a new one (you can put multiple addresses in a single post).

    So integrating these means that you’d want both plug-ins to use the same address fields. That means either rewriting TEC to use the strings from PGM or using the GM functions from PGM to read the fields that TEC uses. Since TEC has active development/support and PGM doesn’t, and since the basic usability of TEC is better, and I don’t see anything wrong with the way TEC stores the addresses, I think a very good solution would be to convert PGM so that it uses the existing TEC address info. Then we can just place the PGM maps into templates and sidebar widgets (that stuff is basically in place).

    I can’t do it all myself. Who else has installed PGM? I can’t see a better basis for this than PGM but if anyone has a better idea, let’s hear it.

    Thread Starter antonlargiader

    (@antonlargiader)

    Do this:

    In list.php change line 60 to this:
    if (!empty( $city ) || !empty( $state ) || !empty( $zip ) ) :

    That says to display the address and GM button if you have ANY of those fields, rather than if you have all of them.

    In t-e-c.php change lines 1328 and 1329 to read:

    } elseif ( !empty( $country ) && !empty( $zip ) ) {
    ???return $google_url . urlencode( $zip . " " . $country);

    And change lines 1371 and 1372 to read:

    } elseif ( !empty( $country ) && !empty( $zip ) ) {
    ???$googleaddress = urlencode( $zip . " " . $country);

    It works for me. I used a hyphen in your postcode so you may want to try that also (or first, if you think you have already made the necessary code changes).

Viewing 15 replies - 1 through 15 (of 34 total)