Soma

MarkupSocialShareButtons

Recommended Posts

Hi Soma !

I saw in theme.php file.

* Alternatively from the API you can set a theme by using method ->setTheme(themename)
 * i.e. $modules->MarkupSocialShareButtons->setTheme("round")->render();
 *
 * To create your own create a file with the content of this file somewhere in your site/templates/ folder
 * This would be a subfolder, and in there a file "theme.php".
 *
 * Now you can enter the path relative from "site/templates" in the module config
 *   $modules->MarkupSocialShareButtons->setTheme("mythemes/mytheme")->render();

I guess I misunderstood this instruction !

Share this post


Link to post
Share on other sites

Ah, thanks for the hint. I see now this is s leftover from a earlier version and forgot to change it there.

  • Like 1

Share this post


Link to post
Share on other sites

You're welcome !

I think that I found the new instruction :

echo $modules->MarkupSocialShareButtons->render(array("theme" => "templates/mythemes/mytheme");

I'm gonna try it !

  • Like 1

Share this post


Link to post
Share on other sites

Updated module today to 1.0.3 with a small fix

- where the markup would break if there's not encoded single quotes in title or texts for linkedin and twitter. It's now using htmlspecialchars_decode() and rawurlencode().

  • Like 3

Share this post


Link to post
Share on other sites

Great module. Love the config options (using FontAwesome).

I've added two custom fields so i can add some more information (event start/end dates).
Probably something for the next update?

thanks!

Share this post


Link to post
Share on other sites

hey Soma, thanks for this, it's working really well for a project i'm doing right now!

I ended up needing to add some classes to the outer wrapper...(the buttons are in a share button which opens a menu)..

i was wondering if you might consider adding a config option at some point for outer wrapper class, if you think that may be of use to others.

Share this post


Link to post
Share on other sites

Outer wrapper? There's none, just an UL

So what I do if needed is like:

echo "<div class='wrapper'>";
echo $modules->MarkupSocialShareButtons->render();
echo "</div>";

Share this post


Link to post
Share on other sites

thx - right, but in my case i needed the class on the UL; i could fiddle with the CSS and see about adding those classes one level up as a wrapper like you have..

Share this post


Link to post
Share on other sites

I see, I'll maybe have a look into but will maybe take some time. It's always a lot of work update a module with readme etc, but will put on my list.

For now I think a better approach would then be this to replace the UL wrapper class, "MarkupSocialShareButtons", with your own class or extend it:

 
$content .= str_replace("MarkupSocialShareButtons cf", "myClasses", $modules->MarkupSocialShareButtons->render());
  • Like 1

Share this post


Link to post
Share on other sites

I see, I'll maybe have a look into but will maybe take some time. It's always a lot of work update a module with readme etc, but will put on my list.

For now I think a better approach would then be this to replace the UL wrapper class, "MarkupSocialShareButtons", with your own class or extend it:

$content .= str_replace("MarkupSocialShareButtons cf", "myClasses", $modules->MarkupSocialShareButtons->render());

yeah, this is totally fine with me (didn't think of doing it this way.)... leave the module!

Share this post


Link to post
Share on other sites

Hi Soma, the Validator is still complaining about missing alt tags (in the theme templates)...

Share this post


Link to post
Share on other sites

Hi Soma,

great module!

But i have a problem with the facebook share button:
I want sometimes not the first but the second image to be shared on facebook.
Where can i define which image will be transferred to facebook?

Or is this managed by og-tags?
 

Thanks!!!

 

Share this post


Link to post
Share on other sites
19 hours ago, tires said:

Hi Soma,

great module!

But i have a problem with the facebook share button:
I want sometimes not the first but the second image to be shared on facebook.
Where can i define which image will be transferred to facebook?

Or is this managed by og-tags?
 

Thanks!!!

 

Thanks. Yes the facebook grabs the image from wherever it finds it first.

Share this post


Link to post
Share on other sites
On 9/21/2016 at 8:03 AM, tires said:

Hi Soma,

great module!

But i have a problem with the facebook share button:
I want sometimes not the first but the second image to be shared on facebook.
Where can i define which image will be transferred to facebook?

Or is this managed by og-tags?
 

Thanks!!!

It is definitely managed by OG tags - if you have the correct meta then FB will use your specified OG image, otherwise it will search for and use the first image.

here is an example

<meta property='og:title' content='###' />
<meta property='og:type' content='website' />
<meta property='og:site_name' content='###' />
<meta property='og:locale' content='en_US' />
<meta property='og:url' content='http://www.website.com/' />
<meta property='og:description' content='###' />
<meta property='og:image' content='http://www.website.com/site/assets/files/####/image.1200x630.jpg' />
<meta property='og:image:url' content='http://www.website.com/site/assets/files/####/image.1200x630.jpg' />
<meta property='og:image:type' content='jpg' />
<meta property='og:image:width' content='1200' />
<meta property='og:image:height' content='630' />

 

Share this post


Link to post
Share on other sites
23 hours ago, Macrura said:

It is definitely managed by OG tags - if you have the correct meta then FB will use your specified OG image, otherwise it will search for and use the first image.

here is an example


<meta property='og:title' content='###' />
<meta property='og:type' content='website' />
<meta property='og:site_name' content='###' />
<meta property='og:locale' content='en_US' />
<meta property='og:url' content='http://www.website.com/' />
<meta property='og:description' content='###' />
<meta property='og:image' content='http://www.website.com/site/assets/files/####/image.1200x630.jpg' />
<meta property='og:image:url' content='http://www.website.com/site/assets/files/####/image.1200x630.jpg' />
<meta property='og:image:type' content='jpg' />
<meta property='og:image:width' content='1200' />
<meta property='og:image:height' content='630' />

 

I used the Markup SEO modul         side by side with this module.
The seo module creates die og tags automatically (and left the og:image was always blank).

I solved it by putting the og tags manually in my head.inc and fill it with:

<meta property="og:image" content="<?php echo 'http://'.$_SERVER['HTTP_HOST'].$page->myimage2->url; ?>" />
<meta property="og:image:width" content="<?php echo $page->myimage->width; ?>" />
<meta property="og:image:height" content="<?php echo $page->myimage->height; ?>" />

That works well!

Thanks an best regards!
 

Share this post


Link to post
Share on other sites

@Soma

Using this for the first and it's awesomely flexible - thank you!

One problem is that some of the $option parameters aren't correctly overriding the defaults. So far I know that these two don't, but there might be others:

outer_wrapper_tag
item_wrapper_tag

The other suggestion I have is an option (or maybe it should just be the default) is to use the full http url to the icon images. I know this can be adjusted in the theme.php file, but it means you need a custom theme to make this work. The reason I want this is for inserting the icons into an outgoing email.

Thanks.

Share this post


Link to post
Share on other sites

hi !

can anyone specify where is the template located,

i feel it irritated to do

$content .= str_replace("MarkupSocialShareButtons cf", "myClasses", $modules->MarkupSocialShareButtons->render());

also i need to add other elements across the output? 

Share this post


Link to post
Share on other sites

it would be cool if the classes were a field in the module config, so you could add or change them

Share this post


Link to post
Share on other sites

I think its better to have a tpl, so its easier to redo it manually with repeaters and a single php 

Share this post


Link to post
Share on other sites

Hi, I can't understand why this happens:

Ex Facebook:

I tried to post the link on the facebook page and form there I can see Title, Description and the image. But If use the share button this doesn't work in the same way.

This is my options chosen for facebook:

  • ?url={url} --> I see only the link (this is correct)
  • ?url={url}&title={title}&text={text}&media={media}   -->  I see only the link

Ugual for Pinterest and for twitter not take any image.

  • Pinterest  -->  ?media={media}&url={url}&description={text}
  • Twitter --> ?url={url}&title={title}&text={text}&media={media}

 

I  try to set the {media} for take the field where is my image but probably I set it wrong.

How I can do ?

 

 

Share this post


Link to post
Share on other sites

Hi everyone!

How I can set correctly the media={media} ? Because at moment no social uploads any image, ex: on Pinterest the html output miss the SRC attribute

to try to set the media I try to use my image filed but doesn't work. I try in the module and also in the backend. But the page load a src={my_filed}.

Any Idea? What I can do?

Thank you

Share this post


Link to post
Share on other sites

@MarcoPLY,

I've never tried the media={media} parameter;

But in general the way this works is you have to have the correct markup on the page itself, meaning valid og tags and twitter card in the header. Maybe you already know this and are trying to override, but if not....

<meta property='og:image' content='bsolute/link/to/image.jpg' />
<meta property='og:image:url' content='absolute/link/to/image.jpg' />
<meta property='og:image:type' content='png' />
<meta property='og:image:width' content='1200' />
<meta property='og:image:height' content='630' />
<meta name='twitter:card' content='summary_large_image' />
<meta name='twitter:site' content='your-twitter-handle' />
<meta name='twitter:title' content='Page Title' />
<meta name='twitter:description' content='Some description' />
<meta name='twitter:creator' content='your-twitter-handle' />
<meta name='twitter:image:src' content='absolute/link/to/image.jpg' />

 

Share this post


Link to post
Share on other sites

"media" can (as any) or must be set by the options array you give the render() method.

$options = array(
	"media" => $page->image->httpUrl()
);
echo $modules->MarkupSociaShareButtons->render($options);

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By daniels
      General
      This is a lightweight alternative to other newsletter & newsletter-subscription modules.
      It can subscribe, update, unsubscribe & delete a user in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin.
      This module fits your needs if you...
      ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe, update, unsubscribe or delete users to/from different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns You can find it here: https://github.com/danielstieber/SubscribeToMailchimp
      Let me know what you think and if I should add it to the Modules Directory.
      Setup
      Log into your Mailchimp account and go to  Profile > Extras > API Keys. If you don't have an API Key, create a new one. Copy your API Key and paste it in the module settings (Processwire > Modules > Site > SubscribeToMailchimp). Back in Mailchimp, go to the list, where you want your new subscribers. Go to Settings > List name and defaults. Copy the List ID an paste it in to the module settings.
      Usage
      To use the module, you need to load it into your template:
      $mc = $modules->get("SubscribeToMailchimp"); Now you can pass an email address to the module and it will try to edit (if the user exists) or create a new subscriber in your list.
      $mc->subscribe('john.doe@example.com'); You can also pass a data array, to add additional info.
      $mc->subscribe('john.doe@example.com', ['FNAME' => 'John', 'LNAME' => 'Doe']); You can even choose an alternative list, if you don't want this subscriber in your default list.
      $mc->subscribe('john.doe@example.com', ['FNAME' => 'John', 'LNAME' => 'Doe'], 'abcdef1356'); // Subscribe to List ID abcdef1356 If you want to unsubscribe a user from a list, you can use the unsubscribe method.
      $mc->unsubscribe('john.doe@example.com'); // Unsubscribe john.doe@example.com from the default list $mc->unsubscribe('john.doe@example.com', 'abcdef1356'); // Unsubscribe john.doe@example.com from the list abcdef1356 If you want to permantly delete a user, you can call the delete method. Carefully, this step cannot be undone
      $mc->delete('john.doe@example.com'); // Permanently deletes john.doe@example.com from the default list $mc->delete('john.doe@example.com', 'abcdef1356'); // Permanently deletes john.doe@example.com from the list abcdef1356  
      Important Notes
      This module does not do any data validation. Use a sever-sided validation like Valitron Make sure that you have set up your fields in your Mailchimp list. You can do it at Settings > List fields and *|MERGE|* tags Example
      Example usage after a form is submitted on your page:
      // ... validation of form data $mc = $modules->get("SubscribeToMailchimp"); $email = $input->post->email; $subscriber = [ 'FNAME' => $input->post->firstname, 'LNAME' => $input->post->lastname, ]; $mc->subscribe($email, $subscriber);  
      Troubleshooting
      In case of trouble check your ProcessWire warning logs.
      I can't see the subscriber in the list
      If you have enabled double opt-in (it is enabled by default) you will not see the subscriber, until he confirmed the subscription in the email sent by Mailchimp
      I get an error in my ProccessWire warning logs
      Check if you have the right List ID and API Key. Check if you pass fields, that exist in your list. Check if you pass a valid email address. Go to Mailchimps Error Glossary for more Information
      How To Install
      Download the zip file at Github or clone directly the repo into your site/modules If you downloaded the zip file, extract it in your sites/modules directory. You might have to change the folders name to 'SubscribeToMailchimp'. Goto the modules admin page, click on refresh and install it  
      Changelog
      0.0.2
      Note: You can update safely from 0.0.1 without any changes in your code
      New Features
      Added 'Unsubscribe' method $mc->unsubscribe($email, $list = "") Added 'Delete' method $mc->delete($email, $list = "") Bug Fixes and compatibility changes
      Removed type declarations to be compatible with PHP 5.1+* (thanks to wbmnfktr) Other
      Changed the way, the base url for the api gets called *I have only tested it with PHP 7.x so far, so use on owners risk
    • By BitPoet
      As threatened in the Pub sub forum in the "What are you currently building?" thread, I've toyed around with Collabora CODE and built file editing capabilities for office documents (Libre-/OpenOffice formats and MS Office as well as a few really old file types) into a PW module.
      If you are running OwnCloud or NextCloud, you'll perhaps be familiar with the Collabora app for this purpose.
      LoolEditor
      Edit office files directly in ProcessWire
      Edit your docx, odt, pptx, xlsx or whatever office files you have stored in your file fields directly from ProcessWire's page editor. Upload, click the edit icon, make your changes and save. Can be enabled per field, even in template context.
      Currently supports opening and saving of office documents. Locking functionality is in development.
      See the README on GitHub for installation instructions. You should be reasonably experienced with configuring HTTPS and running docker images to get things set up quickly.
      Pull requests are welcome!
      Here is a short demonstration:

    • By Robin S
      An Images field allows you to:
      Rename images by clicking the filename in the edit panel or in list view. Replace images, keeping metadata and filename (when possible) by dropping a new image on the thumbnail in the edit panel. Introduced here. But neither of these things is possible in File fields, which prompted this module. The way that files are renamed or replaced in this module is not as slick as in the Images field but it gets the job done. The most time-consuming part was dealing with the UI differences of the core admin themes. @tpr, gives me even more respect for the work that must go into AdminOnSteroids.
      Most of the code to support the rename/replace features is already present in InputfieldFile - there is just no UI for it currently. So hopefully that means these features will be offered in the core soon and this module can become obsolete.
       
      Files Rename Replace
      Allows files to be renamed or replaced in Page Edit.

      Usage
      Install the Files Rename Replace module.
      If you want to limit the module to certain roles only, select the roles in the module config. If no roles are selected then any role may rename/replace files.
      In Page Edit, click "Rename/Replace" for a file...
      Rename
      Use the text input to edit the existing name (excluding file extension).
      Replace
      Use the "Replace with" select to choose a replacement file from the same field. On page save the file will be replaced with the file you selected. Metadata (description, tags) will be retained, and the filename also if the file extensions are the same.
      Tip: newly uploaded files will appear in the "Replace with" select after the page has been saved.
       
      https://github.com/Toutouwai/FilesRenameReplace
      http://modules.processwire.com/modules/files-rename-replace/
    • By d'Hinnisdaël
      So I decided to wade into module development and created a wrapper module around ImageOptim, a service that compresses and optimizes images in the cloud. ImageOptim currently handles JPG, PNG and GIF files and, depending on the settings you use, shaves off between 15% and 60% in filesize. Great for bandwidth and great for users, especially on mobile.
      This module handles the part of uploading images to ImageOptim via their official API, downloading the optimized version and storing it alongside the original image.
       

       
      Download & Info
      GitHub / Module directory / Readme / Usage
       
      Why ImageOptim?
      There are other image optimization services out there, some of them free, that have outstanding ProcessWire modules. A few things make ImageOptim the best tool for most of my customers: It's not free, i.e. it will probably be around for a while and offers support. However, it's cheaper than some of the bigger competitors like Cloudinary. And it does PNG compression better than any of the free services out there, especially those with alpha channels.
       
      Installation
      Install the module like any other ProcessWire module, by either copying the folder into your modules folder or installing it via the admin. See above for downloads links on GitHub and in the module directory.
       
      Requirements
      To be able to upload images to the service, allow_url_fopen must be set on the server. The module will abort installation if that's not the case.
      I have only tested the module on ProcessWire 3.x installations. I don't see why it shouldn't work in 2.x, if anyone wants to try it out and report back.
       
      ImageOptim account
      To compress images, you first need to sign up for an ImageOptim account. They offer free trials to try the service.
       
      Usage (manual optimization)
      Images can be optimized by calling the optimize() method on any image. You can pass an options array to set ImageOptim API parameters.
      $image->size(800,600)->optimize()->url $image->optimize(['quality' => 'low', 'dpr' => 2]) // Set quality to low and enable hi-dpi mode
      Automatic optimization
      The module also has an automatic mode that optimizes all image variations after resizing. This is the recommended way to use this module since it leaves the original image uncompressed, but optimizes all derivative images.
      $image->size(800,600)->url // nothing to do here; image is optimized automatically
      To change compression setting for single images, you can pass an options array along with the standard ImageResizer options. Passing false disables optimization.
      $image->size(800, 600, ['optimize' => 'medium']) $image->size(800, 600, ['optimize' => ['quality' => 'low', 'dpr' => 2]]) $image->size(800, 600, ['optimize' => false])
      For detailed usage instructions and all API parameters, see the usage instructions on GitHub.
       
      Filenames
      Optimized images will be suffixed, e.g. image.jpg becomes image.optim.jpg. You can configure the suffix in the module settings.
       
      Roadmap
      Asynchronous processing. Not really high on the list. Image variations need to be created anyway, so waiting a few seconds longer on first load is preferable to adding complexity to achieve async optimization. Optimize image variations created by other modules. CroppableImage comes to mind. I don't use any of these, so if somebody wants to help out and submit a pull request — all for it! Add a dedicated page in the setup menu with a dashboard and detailed statistics. ImageOptim's API is very barebones for now, so not sure if that's feasible or even necessary.
      Stability
      I've been using this module on production sites for some time now, without hiccups. If you do notice oddities, feel free to comment here or investigate and submit PRs.
    • By PWaddict
      Module for hiding pages for non-superusers.
      Download
      HidePages
      Requirements
      ProcessWire 3.x Changelog
      1.0.1 (31 March 2018)
      Module renamed to prevent confusion 1.0.0 (30 March 2018)
      Initial release