Posts by kdl

    Hi,


    I have the Blog app running and I am using perch_content_custom to not only return a list of blog entries, but also, I am using it to return entries designated as 'most popular' and 'most recent' in a sidebar.


    The issue is, as soon as implement pagination on the post.php page, the main perch_content_custom call, which returns the listing of blog entries and is first on the page updates fine, but all content in the subsequent calls is lost.


    Is there a way to retain the content with pagination.


    The main template (index.php) looks like:



    Now I realise that the pagination is set within the template 'blog_post_in_list.html' which would then only effect that main element:


    Code
    1. <perch:template path="pagination/default.html" rescope="parent">


    but then how do I either move pagination to within index.php as <perch:template> cannot be directly applied, or do I somehow have to try and include the sidebar content within my 'blog_post_in_list.html' which I cannot see how to do, to get the pagination working.


    That is, the bog posts are paginated, but the content in the sidebar (post_in_list_popular_comments.html and post_in_list_recent.html) are not.


    Any ideas welcome.


    Thanks,


    Andy

    Hi,


    I'm sure I am just overlooking something obvious here, but let's say I have a contact form and I want this to to be within certain templates, i.e. the form appears on the homepage and a specific contact page, how do I use the same form in different templates.


    If I add the usual content call:

    PHP
    1. <?php perch_content('Contact Form'); ?>

    on both templates, I can get the responses stored in the same place, but one of the instances shows the 'success' message and the other doesn't. This seems to be linked to the fact that the admin has generated two instances of the 'success' input area, which I am presuming are conflicting.


    I am sure it can be done.


    Using perch_layout doesn't work. but there must be a way of including the form, without generating a new instance of it.


    Not sure if I am explaining it very well. It's late and I'm tired ! :(


    I am sure the penny will drop soon.


    Any quick pointers would be appreciated.


    Thanks

    Yep, as expected (but thought I might be going mad and doubting myself), it is there, listed under Extensions:

    Quote

    Extensions: Core, bcmath, calendar, ctype, date, filter, hash, iconv, json, mcrypt, SPL, pcre, Reflection, session, standard, mysqlnd, tokenizer, zip, zlib, libxml, dom, PDO, bz2, SimpleXML, xml, wddx, xmlreader, xmlwriter, apache2handler, openssl, curl, fileinfo, gd, gettext, mbstring, exif, mysqli, pdo_mysql, pdo_sqlite, Phar, ftp, Zend OPcache

    There must be something failing the function, as, once it is in the !isset element as mentioned above, I just cannot see how it escapes the return -1; item, to then process further.


    Obviously it must work for some people as surely everybody would be on this forum complaining that the Perch Twitter App doesn't work ?


    Thanks for all your responses and a big thank you to your mention about adding /perch/addons/apps/perch_twitter/settings/ to the callback url. This should really be added to the documentation as I've had this issue for ages (never got past the setup and as such gave up on the Twitter App completely for a while).

    Would have done it again, but client is adamant about having Twitter feed on the site and why not, should be fairly simple. Might have to look at other widgets, but at least I've got the Perch App working now, just not an elegant solution, or, inline with Perch. Hate hacking code.

    Ok, so looking into things (and not sure why I am doubting myself but it's been a long frustrating road), it seems I am correct in the fact that JSON is complied in my PHP installation. Infact, I would have done pretty well (or be using a very old version) to have not had.


    I've looked at PerchTwitter.class.php (line 162 - 166), some more:


    Code
    1. if (!isset($item->error)) {
    2. return $item->html;
    3. }
    4. return -1;

    and have come to some form of conclusion. Firstly, I'm not 100% sure how, within the scheme of this file, the process ever gets past the return -1 item to process anything else in the file. Just doesn't quite makes sense to me.


    Removing the above code from the file does allow me to now return and display the tweets without error, just in raw html format.


    As such, changing the tweet.html template to:


    Code
    1. <perch:twitter id="tweetHTML" encode="false" />

    allows the tweets to be rendered in html.


    This now returns the latest 3 tweets, although the formatting is not what I expected, with no options for retweets, follow etc, but I guess I can build a custom template for this.

    Before anyone says it, I do not like editing CORE code, but this fix worked for me. It's not the answer, there is definitely something not quite right with the PerchTwitter.class.php script, but with client pressures and demands, I will try and take a look at this asap and see if I can figure it out, or what infact the offending lines of code are doing.


    Not sure if, when Perch 4 is delivered, a new Twitter App will also be updated, or it will work, but I really wanted to keep using the Twitter App, rather than looking at alternative solutions.


    I love Perch and it's frustrating but these things happen. Surely cannot be the only one who has encountered this problem and hopefully this workaround, albeit I'm sure, temporary will help a few people out.

    I'm running XAMPP Version: 7.0.4, but not sure if this ships as standard install with PHP JSON library or not.


    Is this something that should show up in the extended diagnostics from the Perch installation ?

    ergrge


    Yes, as suspected, I have tried all permutations and still the above line 163 error.


    That is, I have used:


    addons/apps/perch_twitter/settings/


    Your Twitter username (required): @KLSSupportUK and KLSSupportUK


    with:


    PHP
    1. <?php
    2.     perch_twitter_get_latest(array(
    3.         'twitter_id'=>'KLSSupportUK',
    4.         'type'=>'mine',
    5.         'count'=>3
    6.     ));
    7. ?>


    PHP
    1. <?php
    2. perch_twitter_get_latest(array(
    3. 'twitter_id'=>'@KLSSupportUK',
    4. 'type'=>'mine',
    5. 'count'=>3
    6. ));
    7. ?>


    PHP
    1. <?php
    2.     perch_twitter_get_latest();
    3.     perch_twitter_widget_js();
    4. ?>


    The only thing that starts to allow the displaying of the tweets is the removal of the code around stated line 163 in PerchTwitter.class.php.


    The setup is authorising, bringing down tweets with no error anymore (when code removed), so it must be something to do with:


    Code
    1. return $item->html;


    failing, as this, I presume is allowing the tweet to be rendered in html format.

    Hi Drew,


    Removing the @ from the 'Your Twitter username' in the perch twitter settings page, still produces all of the aforementioned errors. It's still failing at this line 163 item within PerchTwitter.class.php.


    I will try going back to using a custom call for the rendering of the tweets, as this was the only place that HAD used the @KLSupportUK name, but I cannot see this being any part of the issue.

    OK MAYBE GETTING SOMEWHERE.


    If I clear the perch3_twitter_tweets table and remove the below code from PerchTwitter.class.php (line 162 - 166):

    Code
    1. if (!isset($item->error)) {
    2. return $item->html;
    3. }
    4. return -1;

    Then press 'Get Tweets', the tweets import without error and I can see the raw html on the site !!!.

    It's something !!!!!!


    So, the Million Dollar Question is, why does the above code trigger all these issues ? and what could I try to resolve it.

    OK MAYBE GETTING SOMEWHERE.


    If I clear the perch3_twitter_tweets table and remove the below code from PerchTwitter.class.php (line 162 - 166):

    Code
    1. if (!isset($item->error)) {
    2. return $item->html;
    3. }
    4. return -1;

    Then press 'Get Tweets', the tweets import without error and I can see the raw html on the site !!!.

    It's something !!!!!!


    So, the Million Dollar Question is, why does the above code trigger all these issues ? and what could I try to resolve it.

    This is getting so frustrating.


    I decided to delete the 'Twitter App' and rebuild it.


    I gave the app the actual site url, but the callback is for my locally hosted version with the additional item route to the settings:


    Quote

    http://[mylocaldomain]/admin/addons/apps/perch_twitter/settings/

    New App Authenticates fine...yay.


    But as soon as I go to retrieve Tweets I get ALL the errors mentioned above, so something is definitely not right, especially if there is a known bug in the Perch Twitter App that requires this additional routing to the callbackURL. Surely other people are finding this. Maybe they are just not using the Twitter App ? Might have to look at some alternative.


    Usual errors when pressing 'Get Tweets':

    Quote

    Notice: Trying to get property of non-object in C:\KDL-Projects\Open\kdl_kls\www\admin\addons\apps\perch_twitter\PerchTwitter.class.php on line 163


    Warning: Cannot modify header information - headers already sent by (output started at C:\KDL-Projects\Open\kdl_kls\www\admin\addons\apps\perch_twitter\PerchTwitter.class.php:163) in C:\KDL-Projects\Open\kdl_kls\www\admin\core\lib\PerchUtil.class.php on line 1405


    Warning: Cannot modify header information - headers already sent by (output started at C:\KDL-Projects\Open\kdl_kls\www\admin\addons\apps\perch_twitter\PerchTwitter.class.php:163) in C:\KDL-Projects\Open\kdl_kls\www\admin\core\inc\top.php on line 17


    The perch3_twitter_tweets table gets updated with all the tweets and I can see them in the Admin (Listing Tweets page), so the app has downloaded and worked, so it MUST be perch side.


    The DEBUG shows:

    Code
    1. Array
    2. (
    3. [type] => 2
    4. [message] => Cannot modify header information - headers already sent by (output started at C:\KDL-Projects\Open\kdl_kls\www\admin\addons\apps\perch_twitter\PerchTwitter.class.php:163)
    5. [file] => C:\KDL-Projects\Open\kdl_kls\www\admin\core\inc\top.php
    6. [line] => 17
    7. )

    which points to this mysterious issue around line 163, but all this has is:

    Code
    1. if (!isset($item->error)) {
    2.     return $item->html;
    3. }



    If I press 'Get Tweets' again (for second time), the errors disappear, but still no display.

    Hmm, interestingly, when I put a new copy onto the live server (temp domain), it doesn't get past the twitter authentication. At the top of the page I get the message "There was an error".


    Debug shows me:


    Code
    1. Array
    2. (
    3. [type] => 2
    4. [message] => Cannot modify header information - headers already sent by (output started at /home/klssupportuk/public_html/admin/addons/apps/perch_twitter/modes/settings.pre.php:59)
    5. [file] => /home/klssupportuk/public_html/admin/core/inc/top.php
    6. [line] => 17
    7. )

    which is a tad odd......

    Yes, the perch3_twitter_tweets table has all the entries in there, so that's not the issue.


    Ok, so I emptied the table. Went back into Perch and reauthenticated the App, which was fine, then when I go to Tweets and hit 'Get Tweets', I get a number of errors.


    Quote

    Notice: Trying to get property of non-object in C:\KDL-Projects\Open\kdl_kls\www\admin\addons\apps\perch_twitter\PerchTwitter.class.php on line 163

    This error repeats itself a number of times...I presume the amount of tweets it's pulled down.


    Quote

    Warning: Cannot modify header information - headers already sent by (output started at C:\KDL-Projects\Open\kdl_kls\www\admin\addons\apps\perch_twitter\PerchTwitter.class.php:163) in C:\KDL-Projects\Open\kdl_kls\www\admin\core\lib\PerchUtil.class.php on line 1405

    The above, which I presume is die to the previous error and then lastly...


    Quote

    Warning: Cannot modify header information - headers already sent by (output started at C:\KDL-Projects\Open\kdl_kls\www\admin\addons\apps\perch_twitter\PerchTwitter.class.php:163) in C:\KDL-Projects\Open\kdl_kls\www\admin\core\inc\top.php on line 17

    which again, I presume is due to the first one, just having the same item called in a different file.


    So, dealing with my first error, if I look at the file PerchTwitter.class.php we get on line 163:


    Code
    1. if (!isset($item->error)) {
    2. return $item->html; <--- THIS IS LINE 163
    3. }


    I had found this post but no resolution, same problem though - http://forum.grabaperch.com/fo…playing-on-site-home-page


    Just a thought, it's not something as daft as windows using forward slashes rather than backslashes ?


    Grasping at straws here.


    I will upload everything to the proper server (this is currently on XAMPP on windows) to see if it works there. STill, there must be loads of people working on local copies (XAMPP) on a PC.

    It's just really odd, I can 'Get Tweets' and I get the green bar with all tweets updated, no errors. I can go into the perch twitter settings and force re-authentication and it brings me back to the site fine, no errors. The DB has the tweets within it, so I would now presume, the strict bit of Twitter has happened and now it's just an issue with Perch rendering them to the screen.

    My light blue tad has '3' in it, as expected.


    I've already reinstalled the twitter app once and I've even got a new copy (download) in-case there had been some update or corruption on download. I've even tried a different users credentials on Twitter to see if I can display other tweets.


    Really at a loss here, as it all seems ok, but just not rendering the retrieved tweets.

    If I'm correct in thinking, the LIMIT statement would 'limit' the records returned, yet, I can see that the template is called and loops 3times, so I presume this element has nothing to do with it.


    I also presume the tweetIsReply item would be driven via Perch itself to navigate through the tweets and pullback just the required items, i.e. only my tweets, include replies, other peoples tweets etc.


    Ahh, yes, slight apologies. I'm pulling tweets back in multiple pages and I have used different calls to retreive the tweets, thinking it might be something to do with this.

    The above SQL statement was a result from the call:


    PHP
    1. <?php
    2.     perch_twitter_get_latest(array(
    3.     'twitter_id'=>'@KLSSupportUK',
    4. 'type'=>'mine',
    5. 'count'=>1
    6. ));
    7. ?>


    So if I go back to the standard call of:


    PHP
    1. <?php
    2. perch_twitter_get_latest();
    3. perch_twitter_widget_js();
    4. ?>


    My debug becomes:


    SQL
    1. SELECT * FROM perch3_twitter_tweets WHERE tweetType='mine' AND tweetAccount='@KLSSupportUK' ORDER BY tweetDate DESC LIMIT 3


    So again, just the tweetIsReply element missing.


    This does not display any records, but if I add some text to the template, I can see on the page that it has looped through 3 times, so it's finding the 'tweet.html' template, but just not rendering the tweets themselves.


    Any ideas ?


    Thanks, really appreciated.

    My debug returns


    SQL
    1. SELECT * FROM perch3_twitter_tweets WHERE tweetType='mine' AND tweetAccount='@KLSSupportUK' ORDER BY tweetDate DESC LIMIT 1

    So the only difference I can see is the:


    AND tweetIsReply=0


    LIMIT 1 element


    I will look into what these elements are doing or how you can adjust them.