Skip to content

Instantly share code, notes, and snippets.

View madebymats's full-sized avatar

Mats Neander madebymats

View GitHub Profile
@somatonic
somatonic / repeater_example.php
Last active September 24, 2021 12:19
example repeater creation and save front-end form
<?php
$mypage = $pages->get("/about/");
if($input->post->submit){
$n = 1;
$title = "element_title_$n";
$url = "external_url_$n";
$mypage->setOutputFormatting(false);
@somatonic
somatonic / inputfieldfile-form.php
Last active March 31, 2023 01:14
ProcessWire front-end upload form example using ProcessWire Inputfields and form processing.
<?php
/**
* ProcessWire (2.5) InputfieldFile front-end upload form example
* Various workarounds to get it working with Errors for WireUpload
* and removing files upload after error
*/
$sent = false;
$upload_path = $config->uploadTmpDir;
@somatonic
somatonic / form-process.php
Last active May 24, 2023 18:26
ProcessWire example front-end form with file upload and fields
<?php
// ------------------------------ FORM Processing ---------------------------------------
$errors = null;
$success = false;
// helper function to format form errors
function showError($e){
return "<p class='error'>$e</p>";
@somatonic
somatonic / from.php
Last active June 26, 2018 19:23
Create a page edit form on frontend using PW API and fields from the template of the page
<?php
// get a page
$editpage = $pages->get("/editme/");
$ignorefields = array("isOld","language_published");
$form = $modules->get("InputfieldForm");
$form->method = 'post';
$form->action = './';
@somatonic
somatonic / upload_images_to_page_form.php
Created November 26, 2012 22:08
Upload Images to new created Page Form Example
<?php
// front-end form example with multiple images upload
// add new page created on the fly and adding images
$message = '';
if($input->post->submit){
// tmp upload folder for additional security
@jonathanmoore
jonathanmoore / gist:2640302
Created May 8, 2012 23:17
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter