-
Posts
51 -
Joined
-
Last visited
Everything posted by Ferdi Derksen
-
Hi all, 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. Uses (included) TwitterOAuth PHP library written by abraham. http://modules.processwire.com/modules/publish-to-twitter/ https://github.com/FerdiAgrio/PublishToTwitter Enjoy!
- 31 replies
-
- 14
-
Hi Martijn, Well, I'm not sure this will do since my code needs the JS library only once. In my case (charts-module ) I need to load the highcharts library only once, but the page (body) can have multiple instances of hanna code; [[chart item=a period=month]] some text here [[chart item=b period=3months]] //and so on... ...and in case we have other hanna-codes in the body/page, I need to make sure my library is already added or if I still need to load it.
-
After searching for a way to load a JS library once when looping through multiple hanna-codes (of the same type) at a page, I came up with the following solution; if (!isset($hanna->jsloaded)) $this->config->scripts->append('myJS.js'); $hanna->jsloaded = 1; // do other stuff Is this the correct way to do such loading? Session- or normal variables cannot be used since they keep on remembering or resetting the values during the process of loading pages (ones or multiple times).
-
Hi all, First of all - keep in mind I'm not that experienced creating modules / general ProcessWire... I'm creating a module which can be used to tweet a page when saving it. When building this module, the following issue came up; My module has multiple (text) inputfields for connecting to OAuth (http://oauth.net), so as minimal as four fields should be set before an attempt to connect will be done, so no default values can be set. Only when saving the module, I cannot test the connection directly with the new posted data, why? When tested multiple times with a lot of different settings, the first message is a succesful connection to Twitter, and a few lines later the message is failed (or vice-versa depending on posted data). What am I missing/doing wrong? edit: I'm overwriting the $data variables with post data, but in my opinion this shouldn't be the case $wp = wire()->input->post; /** * Set required fields for use of this module * * @return InputfieldWrapper */ public function getModuleConfigInputfields(array $data) { $modules = wire('modules'); $templates = wire('templates'); $fields = wire('fields'); $fieldgroups = wire('fieldgroups'); foreach(self::getDefaultConfig() as $key => $value) { if(!isset($data[$key])) $data[$key] = $value; } // Get default Twitter settings $_ck = $data['publish_to_twitter_consumerkey']; $_cs = $data['publish_to_twitter_consumersecret']; $_at = $data['publish_to_twitter_accesstoken']; $_as = $data['publish_to_twitter_accesstokensecret']; // update/check data only after post $wp = wire()->input->post; if (wire('page')->template == 'admin' && count($wp)) { $_ck = $wp->publish_to_twitter_consumerkey; $_cs = $wp->publish_to_twitter_consumersecret; $_at = $wp->publish_to_twitter_accesstoken; $_as = $wp->publish_to_twitter_accesstokensecret; if(isset($_ck) && isset($_cs) && isset($_at) && isset($_as)) { // wire('session')->message("ck = $_ck"); // wire('session')->message("cs = $_cs"); // wire('session')->message("at = $_at"); // wire('session')->message("as = $_as"); // now we try to connect to Twitter with an OAuth connection and search for hashtag processwire require 'twitteroauth/twitteroauth.php'; $query = array( "q" => '#processwire', "count" => "5", "result_type" => "recent", // "include_entities" => "true", ); $toa = new TwitterOAuth($_ck, $_cs, $_at, $_as); $results = $toa->get('search/tweets', $query); // check if we got any response if (isset($results)) { // check for errors if(isset($results->errors) && count($results->errors)) { foreach($results->errors as $error) { wire('pages')->error("Twitter response: $error->message (Error code: $error->code)"); } } else { // successful connected wire('session')->message("Connection to Twitter was successful"); } } } } $inputfields = new InputfieldWrapper(); // Twitter settings: // Twitter Consumer Key $f = $modules->get('InputfieldText'); $f->attr('name', 'publish_to_twitter_consumerkey'); $f->label = __('Twitter Consumer Key'); $f->required = true; $f->columnWidth = 50; $f->attr('value', $data['publish_to_twitter_consumerkey']); $inputfields->add($f); // Twitter Consumer Secret $f = $modules->get('InputfieldText'); $f->attr('name', 'publish_to_twitter_consumersecret'); $f->label = __('Twitter Consumer Secret'); $f->required = true; $f->columnWidth = 50; $f->attr('value', $data['publish_to_twitter_consumersecret']); $inputfields->add($f); // Twitter Access Token $f = $modules->get('InputfieldText'); $f->attr('name', 'publish_to_twitter_accesstoken'); $f->label = __('Twitter Access Token'); $f->required = true; $f->columnWidth = 50; $f->attr('value', $data['publish_to_twitter_accesstoken']); $inputfields->add($f); // Twitter Access Token Secret $f = $modules->get('InputfieldText'); $f->attr('name', 'publish_to_twitter_accesstokensecret'); $f->label = __('Twitter Access Token Secret'); $f->required = true; $f->columnWidth = 50; $f->attr('value', $data['publish_to_twitter_accesstokensecret']); $inputfields->add($f); return $inputfields; }
-
Not sure, but is it even possible to refer to $input->post->variable without posting to a ProcessWire page? You should post the data to a ProcessWire page like /book/ (which has the book.php file as its template).
-
Please correct me if I'm wrong, but isn't this the same as Event C ? This event is also shown in the results. FYI; the selectors from the other topic also show the same results (B,C,D and E).
-
That's the way I like it, even less code needed Those explanations are completely understandable! Thank you - both Ryan and Diogo for the fast replies.
-
Hi folks, First of all - I'm not sure this is a explainable result - when so please explain (working with PW for only a few weeks now) My website has a lot of events with a start- and enddate. I'm looking for a complete selector which will return the events happening between today (2015-11-06) and a week from now (2015-11-13). I'm searching trough a lot of pages which have the following dates (testcase) ; Title | Startdate | Enddate --------------------------------------------- Event A | 2015-09-21 | 2015-09-22 Event B | 2015-09-21 | 2015-11-10 Event C | 2015-09-21 | 2015-11-30 Event D | 2015-11-07 | 2015-11-08 Event E | 2015-11-07 | 2015-11-19 Event F | 2015-11-18 | 2015-11-19 My expectations are events A and F not to show as a result (they have ended before today or starting after a week from now). Given the dates my selectortest is the following; template=event,enddate>=2015-11-06,enddate<=2015-11-13|startdate<=2015-11-13 ... which results in only Event B and D Simply switching the startdate and enddate did the trick; template=event,enddate>=2015-11-06,startdate<=2015-11-13|enddate<=2015-11-13 ... which results in events B, C, D and E My question, why??
-
Will do - tnx for the info
-
Hi Martijn, Maybe you could have a look at the styling when only one row is set, the scrollbars make editing the row very difficult, especially when there is a large amount of columns set. Tnx in advance and keep up the good work, very pleased with the module! and again tnx for the headsup last Monday! ;-)
-
Worked like a charm! Didn't know this was possible, many thanks! [edit] my initial problem is solved - the bug still stands and will be discussed further at GitHub - https://github.com/ryancramerdesign/ProcessWire/issues/1479
-
@LostKobrakai Thanks for the feedback - but I'm only using the API in this case. I opened a new GitHub issue - https://github.com/ryancramerdesign/ProcessWire/issues/1479
-
That's weird because when testing this on DEV 2.6.19 (also on Master 2.6.1) the following results appear; var_dump(wire('sanitizer')->url("http://")); string 'http://' (length=7) var_dump(filter_var('http://', FILTER_VALIDATE_URL)); boolean false
-
Hi all, I'm pretty new here (working with PW for only a few weeks now) but I can't find out how the $sanitize->url() function should working. In my case the input is only "http://" and I'd expected the sanitizer to result an empty string, this isn't the case and results the exact input value. Is there a explanation for this, or are my expectations off-target? Tnx in advance!