Publish to Twitter module

Recommended Posts

Just in front of the Easterweekend, my first contribution to the modules section of ProcessWire. I created a module to send Tweets when selected at the page editor. From version 0.8.3 up the module is only to use in v3.x. When using ProcessWire v2.x you should use version 0.8.2.

In short this module offers an option to publish a page to Twitter when the date for publishing is past/scheduled.

After filling out the Twitter credentials, select your preferable template(s) which should have the option added to Tweet the pages using it. Additional select the field to use as publicationdate to check if the Tweet should be send now or later, a field which contains the page title.

Optional you can fill out the name of the website which will be added after the title (in case space is available).

Optional you can select the field where the page image(s) are placed (only one will be tweeted).

Optional you can fill out Bit.ly credentials for shortening URLs.

Includes instructions to set a cron (template or LazyCron), returns log in assets folder.

Share this post

Link to post

Share on other sites

Due to the recent Twitter update changes are made to remove the limitation of media-URLs. In addition there is an option to set the maximum number of images you want to add to the Tweet (when the images-field is set to multiple).

Share this post

Link to post

Share on other sites

I installed your module on our test location and it works like a charm. Just one additional question. Would it be possible to execute the same code when a page is created and saved via the (API) $page->save. I added $p->publish_to_twitter = 1; before the $page->save and removed the wire()->input->post->id, but when I open the page just created, the check box is checked, but the page is not (yet) tweeted. Only if I click on save manually again its tweeted. Any idea what I need to amend in the code to get this working?

Cheers

Share this post

Link to post

Share on other sites

First of all I assume you are using the module for version 3.x
I think the first thing to change is the 'autoload' option in the getModuleInfo() method to 'autoload' => true (or add another template you are using for the creation of pages).

Please let me know if that's working for you.

Cheers!

1

Share this post

Link to post

Share on other sites

Thanks. Tried it, and its still not working. I also checked the code and concluded that the somehow the addHookAfter is not triggered, when using the $page->save via the API. I work when using the backend save. Not sure if this is expected behaviour?

Share this post

Link to post

Share on other sites

i just installed the module on a pw3.0.62 and set it up, adding a template as the template whose pages should be tweeted, saved. The module settings "page title field" and the "datefield to check for publication" contain both a drop-down with fields of another template, both drop-downs are slightly different, first being a subset of the other.

Would you have an idea of what went wrong?

I would appreciate any help.

Share this post

Link to post

Share on other sites

There is no limitation/filtering in fields of the selected template(s). Therefore those drop-downs are selecting fields with type "Text" for "page title field" and type "Datetime" for "datefield to check for publication" so the checks when Tweeting (or selecting which to Tweet) can be done properly.

Share this post

Link to post

Share on other sites

There is no limitation/filtering in fields of the selected template(s). Therefore those drop-downs are selecting fields with type "Text" for "page title field" and type "Datetime" for "datefield to check for publication" so the checks when Tweeting (or selecting which to Tweet) can be done properly.

@Ferdi Derksen Let me come back with the earlier reported issue. I do not know what and how happens but: no matter which template is selected on the PublishToTwitter configuration page in the "Publish to twitter template" field, the "page title" and "datefield to check for publication" fields contain a subset of fields used only in the "user" template like "username", "date joined"... (the user template has few more fields that the standard installation.) The "datefield to check for publication" offers items that are not of a date type. The "page images" field gives only one line, images, which is OK. No matter what template is selected in the "publish to twitter templates" field, themisbehaving fields offer the same items.

Would you have any idea what should I check to correct this issue? Would screenshots help?

Share this post

Link to post

Share on other sites

Maybe a stupid question, but you did save the module after selecting a template, right?

The list of fields available is depending on the template(s) you selected at the first place. This should indicate the "user" template is selected now.
On the other hand, the "date" field is build with a selector for fields of type FieldtypeDatetime or FieldtypeText.

Otherwise send/place some screenshots, happy to help!

Share this post

Link to post

Share on other sites

To make sure, I uninstalled the module and installed a fresh from github. Here is how the the config window looks: before selecting any template, the Page title and Datefield to check... are already pre-filled with values that apparently come from the user template.

When the needed template is selected, the options of these two selects do not change. After the config page is submitted/saved, nothing changes -- same old fields as options in the two selects. And they stay the same even when another template is entered and the config page is saved.

Recently Browsing
0 members

Similar Content

I got tired of having to open the link dialog in CKEditor in order to check where a link is pointing to, so made this simple plugin.
Link Hover
A plugin for CKEditor. Shows the href attribute of a link in a tooltip when the link is hovered. This saves you from having to open the link dialog in order to check where a link points to.

Installation
This readme assumes installation in ProcessWire CMS.
The plugin folder must be named "linkhover" – if necessary, rename the folder to remove the "-master" suffix added by GitHub. Copy the "linkhover" folder to /site/modules/InputfieldCKEditor/plugins/
In the field settings for each CKEditor field that you want to activate the plugin for, check the "linkhover" checkbox at Input > Plugins > Extra Plugins

I've been reading through the tutorials and have created an admin module based on the ProcessHello example module.
I have a few questions regarding how to do a few things with the module that are not obvious or covered by the processhello tutorial.
Outline of expected module functionality:
The custom module admin setup page should contain a list of its editable pages.
CMS users will be able to add/edit/delete pages of this module.
The modules editable pages use the same defined fields.
The editable pages data will need to be available for use by another custom module.
This custom module (called "Stream Encoders") will handle creating/updating/deleting of "Stream Encoders".
The encoders contain various fields such as encoder name, operational status (is it on or off) and brightcove asset ID
A second module in "admin>setup" called "Video Streams" will handle creating/updating/deleting/scheduling of "Video Streams".
Each video stream belongs to a video encoder and uses some of the settings from the encoder selected, such as the encoder title and the brightcove asset ID which on the frontend are used to display the video stream.
My noob questions:
Since they are not "pages" in the navigation tree, how do I define these "encoders" to add them to the custom stream encoders module?
I don't believe my custom modules should be under "Setup", is it possible to have custom menus in the admin? It's fine if they can't but it would be more intuitive if they had their own menus in the admin instead of living under "Setup".
Without having a specific page on the frontend for video streams, how would I access the data for a specific video stream from the home page? for example if I wanted to display a specific or random video stream in a sidebar on the homepage.
Are there any tutorials on using scheduling with custom modules? The video streams can be scheduled or turned on/off as desired by the CMS users.
thank you in advance

The module has been lying around on GitHub for some time now, so I thought I'd give it its own forum topic so I can give it a module list entry.
SymmetricEncryptedText
Symmetric encryption for text based fields (supports multi language fields).
Module page.
Link to the GitHub repo.
Description
This module adds an encryption option to all text fields (and those derived from FieldtypeText).
Field contents are encrypted using a symmetric key when a page is saved and decrypted when loaded from the database.
The module by default uses sodium (if loaded) in PHP versions >= 7.2, otherwise it falls back to the bundled phpseclib.
Multi-Language fields are supported too.
WARNING!
Setting a field to encrypted and saving values in those fields is a one-way road!
Once encrypted, the contents cannot be unencrypted without writing a program to do so. Disabling the encryption option on a field after the fact gets you encrypted "garbage".
Usage
Download the zipped module through the green button at the top right of the GitHub repo or (once available there) from the official PW module repository
Extract in its own directory under site/modules.
In the backend, click "Modules" -> "Refresh", then install "Symmetric Encryption for Text Fields".
Go to module settings. An appropriately sized, random key will be generated if this is your first use.
Copy the supplied entry into site/config.php
Add fields or configure already present fields. On the "Details" tab you can enable encryption for the field in question
Edit a page with such a field, enter a value there, save and enjoy
Existing, unencrypted values are left untouched until a new value is saved. That way, you can do a smooth upgrade to encryption, but you have to save all pre-populated pages to have their values encrypted in the database. Thus it is recommended to avoid adding encryption to already populated fields.
Advanced Usage
You can hook after SymmetricEncryptedText::loadKey to retrieve your key from somewhere else, e.g. a different server.

After building the ProcessMentions module and another autocomplete module for images, I found that I am going to need even more of these, but things were going to get repetitive. So I refactored the whole thing into a basic autocompletion module and individual "actions".
The result is Autocomplete for CKEditor (GitHub).
To try out,
Install the module and actions

Enable actions in the settings of any CKEditor field

Edit a page with this field, type "@" and some characters for the and enjoy
There are still a few things I need to implement. ATM, it only supports single characters as triggers for the autocomplete. I'd like to change that to combinations so I don't run out of special characters at some point. I also have to add a few more configuration options (like search only at the beginning or also in the middle of the searched string). The documentation for custom styling also needs some work.
I have tried to keep things generic. Implementing your own actions should be quite straight forward. The README at GitHub illustrates the main steps and the supplied action classes have inline documentation. I would love to get some feedback or even see some third party InlineCompleteAction implementations.

I love the option to export fields via the CMS, and wondered about using that export data in a module. Basicly, I'd want to configure a field using the CMS and then paste it's export data in the module code as a string, or save it in a seperate file I can read from the module code. Once I have that string as a variable or file, I'd want to run the same code the import option does... but then from my module code's install method!
Is that possible? It would save a lot of time configuring fields through the API.