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: Problem

Problems setting up Twitter App.

Perch: 3.0.14, PHP: 5.6.22, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (3.0.14), assets (3.0.14), categories (3.0.14), perch_forms (1.10), perch_twitter (4.0)
App runtimes: <?php $apps_list = ['perch_forms', 'perch_twitter' ];
PERCH_LOGINPATH: /admin
PERCH_PATH: /var/sites/b/bravepr.co.uk/public_html/admin
PERCH_CORE: /var/sites/b/bravepr.co.uk/public_html/admin/core
PERCH_RESFILEPATH: /var/sites/b/bravepr.co.uk/public_html/admin/resources
Image manipulation: GD
PHP limits: Max upload 100M, Max POST 100M, Memory: 128M, Total max file upload: 100M
F1: 3b606135b33e6a102526838f4152a807
Resource folder writeable: Yes
DOCUMENT_ROOT: /var/sites/b/bravepr.co.uk/public_html
HTTP_HOST: bravepr.co.uk
REQUEST_URI: /admin/core/settings/diagnostics/
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php

I have created a html template for a shared footer - in the footer I need to display 1 tweet. I have setup the Twitter App and can see the list of tweets in the control panel.

<section>
        <h3>
        <perch:content id="socialheading" type="text" label="Social heading" required="true" />
    </h3>

<?php
perch_twitter_get_latest([
    'twitter_id'      => '@hellobravepr',
    'type'            => 'mine',
    'count'           => 1,
    'exclude_replies' => true,
    'template'        => 'tweet.html',
]);
?>
</section>

When I refresh the web page, the space where the tweets should appear remains blank.

Any advice would be grateful.

Alex

Alex Brewer

Alex Brewer 0 points

  • 1 year ago
Duncan Revell

Duncan Revell 78 points
Registered Developer

For twitter_id give it a try without the @ symbol - so just 'hellobravepr'

Thanks - still no joy removing the @ symbol.

On the webpage, the tweet space just displays:

'hellobravepr', 'type' => 'mine', 'count' => 1, 'exclude_replies' => true, 'template' => 'tweet.html', ]); ?>

You can’t have php in a template.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you seeing the tweets listed in the control panel?

Hi Drew, yes the tweets are listed in the control panel.

I have setup a global-footer.php which calls a footer.html template. This is a 'shared region' to allow editors to edit 3 of the 4 columns.

The columns are: 1. footer menu (editable) 2. about summary (editable) 3. social media section (not editable) uses perch_twitter_get_latest() 4. contact details (editable)

I guess I need to set this up differently?

Hi Alex

Move the perch_twitter_get_latest php function to your global-footer.php page and then call the tweets inside the template using <perch:twitter id="tweetHTML" encode="false" />.

Jon

Thanks Jon,

So my code in the global-footer.php looks like this:

<?php
perch_twitter_get_latest([
    'twitter_id'      => 'hellobravepr',
    'type'            => 'mine',
    'count'           => 1,
    'exclude_replies' => true,
    'template'        => 'footer-slide.html',
]);
?>
<!-- Footer -->
<footer class="wrapper style1 color3">
    <div class="inner">
        <div class="items style3 small onscroll-fade-in">
            <?php perch_content('Footer Slides'); ?>
        </div>
    </div>
</footer>

and my footer-slide.html template code looks like this:

<section>
        <h3><perch:content id="socialheading" type="text" label="Social heading" required="true" /></h3>
        <perch:twitter id="tweetHTML" encode="false" />
</section>

When I use the developer tools the this is the code being displayed

<section>
<div class="inner">
        <h3>Brave tweet.</h3>
</div>
</section>

The social media area is still blank?

Have you turned on debug to see if there are any messages?

You might want to put the @ symbol back into the username. I use it and it works across many sites.

Still no joy...Do I need to still use...

perch_twitter_widget_js();

I have setup the twitter app in the control panel, I can see a list of tweets but nothing is being displayed.

Have you turned on debug yet to look for error/warning messages?

Hi Jon, debug is turned on...nothing that stands out.

Debug Message - Perch 3.0.14
[1] SELECT u.*, r.* FROM perch3_users u, perch3_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='b9ea7e9cb9d0c1d15d56f871582f20e3' LIMIT 1
UPDATE perch3_users SET userHash='a9e4e2c5eeca30003702febd61dc93f4' WHERE userID='1'
[22] SELECT settingID, settingValue, userID FROM perch3_settings WHERE userID=1 OR userID=0 ORDER BY userID ASC
[8] SELECT itemValue FROM perch3_menu_items WHERE itemType='app'
[1] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=0 ORDER BY itemOrder ASC LIMIT 0, 1
[3] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=1 ORDER BY mi.itemOrder ASC
[1] SELECT itemTitle FROM perch3_menu_items WHERE itemType='app' AND itemValue='settings' LIMIT 1
[1] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=0 ORDER BY itemOrder ASC LIMIT 1, 10
[2] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=2 ORDER BY mi.itemOrder ASC
File: /core/settings/modes/diagnostics.extended.post.php
[26] SHOW TABLES
[0] SELECT COUNT(*) FROM perch3_categories
[0] SELECT COUNT(*) FROM perch3_category_counts
[0] SELECT COUNT(*) FROM perch3_category_sets
[2756] SELECT COUNT(*) FROM perch3_content_index
[516] SELECT COUNT(*) FROM perch3_content_items
[66] SELECT COUNT(*) FROM perch3_content_regions
[1] SELECT COUNT(*) FROM perch3_forms
[1] SELECT COUNT(*) FROM perch3_forms_responses
[10] SELECT COUNT(*) FROM perch3_menu_items
[0] SELECT COUNT(*) FROM perch3_navigation
[0] SELECT COUNT(*) FROM perch3_navigation_pages
[3] SELECT COUNT(*) FROM perch3_page_templates
[16] SELECT COUNT(*) FROM perch3_pages
[726] SELECT COUNT(*) FROM perch3_resource_log
[7] SELECT COUNT(*) FROM perch3_resource_tags
[109] SELECT COUNT(*) FROM perch3_resources
[38] SELECT COUNT(*) FROM perch3_resources_to_tags
[22] SELECT COUNT(*) FROM perch3_settings
[0] SELECT COUNT(*) FROM perch3_twitter_scheduled_tweets
[1] SELECT COUNT(*) FROM perch3_twitter_settings
[50] SELECT COUNT(*) FROM perch3_twitter_tweets
[0] SELECT COUNT(*) FROM perch3_user_passwords
[35] SELECT COUNT(*) FROM perch3_user_privileges
[9] SELECT COUNT(*) FROM perch3_user_role_privileges
[2] SELECT COUNT(*) FROM perch3_user_roles
[4] SELECT COUNT(*) FROM perch3_users
[1] SELECT COUNT(*) FROM perch3_users
[1] SELECT * FROM perch3_twitter_settings LIMIT 1
[22] SELECT DISTINCT settingID, settingValue FROM perch3_settings WHERE userID=0
Queries: 40
Memory: 3.0127
Drew McLellan

Drew McLellan 2638 points
Perch Support

That's the output from the diagnostics page. What's the debug output from the page where you're having problems?

Hi Drew,

See debug from page:

Debug Message - Perch 3.0.14
[1] SELECT u.*, r.* FROM perch3_users u, perch3_user_roles r WHERE u.roleID=r.roleID AND u.userEnabled=1 AND u.userID=1 AND u.userHash='60aa447486902128f0ccd3557a0d445b' LIMIT 1
UPDATE perch3_users SET userHash='b8e8f9904d30e54f31360b1efbc15733' WHERE userID='1'
[22] SELECT settingID, settingValue, userID FROM perch3_settings WHERE userID=1 OR userID=0 ORDER BY userID ASC
[8] SELECT itemValue FROM perch3_menu_items WHERE itemType='app'
[1] SELECT * FROM perch3_content_regions WHERE regionID=6 LIMIT 1
[1] SELECT * FROM perch3_pages WHERE pageID='1' LIMIT 1
Using template: /templates/content/footer-slide.html
[1] SELECT * FROM perch3_content_items c WHERE c.regionID=6 AND c.itemRev=36 ORDER BY c.itemOrder ASC
Using template: /templates/content/footer-slide.html
[1] SELECT * FROM perch3_content_items c WHERE c.regionID=6 AND c.itemRev=36 ORDER BY c.itemOrder ASC
Using template: /templates/content/footer-slide.html
Form not posted or did not validate
[1] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=0 ORDER BY itemOrder ASC LIMIT 0, 1
[3] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=1 ORDER BY mi.itemOrder ASC
[1] SELECT itemTitle FROM perch3_menu_items WHERE itemType='app' AND itemValue='content' LIMIT 1
[1] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=0 ORDER BY itemOrder ASC LIMIT 1, 10
[2] SELECT mi.*, p.privKey FROM perch3_menu_items mi LEFT JOIN perch3_user_privileges p ON mi.privID=p.privID WHERE mi.itemActive=1 AND mi.parentID=2 ORDER BY mi.itemOrder ASC
File: /core/apps/content/modes/edit.form.post.php
[1] SELECT * FROM perch3_resources WHERE resourceID='1' LIMIT 1
Mode: edit.form
Queries: 15
Memory: 4.9949
Drew McLellan

Drew McLellan 2638 points
Perch Support

What still looks like debug from the Perch control panel, not your page.

Hi Dew,

Sorry I've updated the config file with:

define('PERCH_DEBUG', true);

And added the following to the index.php page:

<?php PerchUtil::output_debug(); ?>

No debug appear on screen, just get the debug in the control panel?

Make sure you've added <?php PerchUtil::output_debug(); ?> to the bottom of the page. Otherwise it won't output anything.

Following up - the 'template' was not being picked up.

<?php
perch_twitter_get_latest([
'twitter_id' => '@hellobravepr',
'type' => 'mine',
'count' => 1,
'exclude_replies' => true,
'template' => 'tweet.html',
]);
?>

Should have been:

<?php
perch_twitter_get_latest([
'twitter_id' => '@hellobravepr',
'type' => 'mine',
'count' => 1,
'exclude_replies' => true,
'template' => 'twitter/tweet.html',
]);
?>

Thanks for your support.

Ha - thought that might be the case. Glad you got it sorted. Debug is always the best indicator of template issues. Remember not to have it turned on in production mode!

Jon