We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question, Twitter

User specify number of tweets

Hi,

I am using the twitter app on the latest version of Perch, and have the following code on my page:

    perch_twitter_get_latest([
      'template'=>'twitter/homepage-tweet',
      'count'=>3
    ]);

Is there any way I can let the user specify the count in the template? This is probably simple but I can't work it out.

Thanks!

Short diagnostics below:

Perch: 2.8.31, PHP: 5.6.10, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (2.8.31), assets (2.8.31), categories (2.8.31), perch_blog (5.0), perch_forms (1.8.3), perch_mailchimp (3.0.1), perch_twitter (3.6.2)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_forms', 'perch_mailchimp', 'perch_twitter' );
PERCH_LOGINPATH: /admin
PERCH_PATH: /Users/mikeharrison/Google Drive/Client Work/TW Accountancy/TW Accountancy Build 2/admin
PERCH_CORE: /Users/mikeharrison/Google Drive/Client Work/TW Accountancy/TW Accountancy Build 2/admin/core
PERCH_RESFILEPATH: /Users/mikeharrison/Google Drive/Client Work/TW Accountancy/TW Accountancy Build 2/admin/resources
Image manipulation: GD
PHP limits: Max upload 32M, Max POST 32M, Memory: 128M, Total max file upload: 32M
F1: 2edba60ed1f613d6dd804feb202456a2
Resource folder writeable: Yes
HTTP_HOST: twaccountancy.dev
DOCUMENT_ROOT: /Users/mikeharrison/Google Drive/Client Work/TW Accountancy/TW Accountancy Build 2
REQUEST_URI: /admin/core/settings/diagnostics/
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
Mike Harrison

Mike Harrison 37 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Not in the tweet template, but you can specify it in a regular content template or as a page attribute for example.

Ah ok, yes I hadn't thought of that. Thanks for the help!

For future reference I ended up with this, the count is set in the Introduction Text template, which makes sense for the editor:

perch_content('Introduction Text');

$intro = perch_content_custom('Introduction Text', [
    'skip-template' => 'true'
]);

$tweetcount = $intro['0']['tweet_count'];

perch_twitter_get_latest([
    'count'=>$tweetcount,
    'template'=>'twitter/homepage-tweet'
]);