Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by MilenKo

  1. Huh, as usual, the simplest is always the right solution. That is why I am trying to stay away from templates with different casing names and use something descriptive enough for its purposes. Good that you have sorted out and thanks for coming back to us, as I noted for myself to check the naming if it happens in the real environment
  2. You could try putting TracyDebugger as it always gives me more errors than the standard debug mode. From my humble experience, there got to be something with the access to the templates. Maybe you could try setting one off the template files to 777 and see if that helps. The hosting - is it a server you control or is a shared one? If you have control over the folder, you might want to checck if your webserver (apache, nginx etc.) has its group assigned to read/write. Hope that helps...
  3. @franciccio-ITALIANO I do not thing that somebody other than you could say what is the best practice in such a simple matter so just pick the one you feel is making more sense and try it out. Again, it all depends on your preferences and the idea behind it. We just provided a few ways to accomplish it but the rest is up to you. Try one and see how it works. If not, try the next, the next and so forth until you are good with what you have (at least this is what I do)
  4. @ComputerKid the SkyScraper profile is what several persons (including me) used to disect the code and find out about the power of PW Api. Please, do yourself a favor and do not just install the profile, but have a look "under the hood" and try to assimilate what, how, why etc. I can guarantee you that quite soon you will realize that Wordpress has also nothing comon other than being developed under PHP I worked myself on Wordpress for quite a few users (as an end user) and was not even able to edit some scripting parts to add custom fields etc. Now with PW in zero time I started developing my own theme with quite extensive functionality. And there is so much more to improve my coding skills, so just search the forum, search in google for ProcessWire and you will be more than good to add what is needed to your website
  5. I can confirm that using Incognito mode in Chrome or private in any other browser did the trick and as soon as I am logged-in, the browser shows the value of $user->name correctly. Same thing applies for the comments posted from any account or just as a guest if I unhide the name, email, web etc. It would be interesting to see how to style my form using the default rendering method for the comments as I can apply the styles if I am building a site from scratch however using a premade theme is a bit different story and I should digg deeper into the CSS to make the necessary adjustments to the styles of the comment field to match the design. Anyway it is a learning process and every week I am eager to read about the new stuff and thinking how can I use that. I am doing in paralel a few projects so once I establish the proper way to achieve this and that, the rest would be just to make it work for the specific frontend. Thank you all for the achievements, as i won't make it this far without the shared ideas, advices, best practices and so forth. You are the ones that make PW growing in popularity!
  6. @adrian After a short break and becoming a father for 4th time, I had a few minutes to redo the comments form and it seems to work fine now. The only thing I could think of messing around would be to have some browser cache for the logged on user form. Today I echoed $user->name above the contact form and noticed that I had to refresh a few times before the name of the logged on user shows correctly. As far as I did not yet activate the cache, I would expect it not to happen but will see what can be done. So for now the comments form is working as expected and I can close that chapter as well. I am thinking on adding some email verification if allowing non-registered users to post comments, but that is beyond this topic. So again, thank you very much for the help and sharing.
  7. @adrian I will move it to my online host in a few hours and will share the login details. Thanks in advance to you and @fbg13 again for spotting my silly error.
  8. Oops I did it again... So yes, it was the semicolon which I forgot to put thinking the PC would know my intentions. So back to the point, after adding the semicolon, bd($input->post->cite); returns empty result in 2ms. Unfortunately that does not point me to the reason why it is not populating only in the form but everywhere else in the template it works fine (to call $user->name). Calling bd($user->name) returned empty result as well which should be good but...
  9. Well it appears like any bd i test shows similar error. I will try to remove Tracy and have it reinstalled to see what could be causing the issue (if I am even going to the right direction, however as far as it works with you, but not with me, that has to do something either with the server or pc setup) but not with the code.
  10. Well I put it to the console which I guess was not the smartest thing to do. That is why I get the 500 error... I will need to read more about the Tracy...
  11. Hmm, that is weird as it does not work on two different computers, but will try it on another PC to move the profile and see. I am checking if there are any caches right now but by default I keep them disabled so that should not be the issue. P.S. I ran the bd($input->post->cite) in TracyDebugger and got an error: 500: Internal Server Error See the browser dev console for the actual error It seems like a strange server issue, however if I try to call $user->name somewhere else within the same template, I get the proper value (in my case test). Tried switching up the user and it is always the correct one. Thinking to redo the whole comment form using your earlier example and see if that would help.
  12. @adrian I am not sure how can I debug the $input->post->cite in Tracy Debugger's bd. I tried to unhide the Name and remove the value from it so that it is populated with the field content, but the comment does not show up and is not in NonApproved comments attached to the page. So something must be wrong with the form submission...
  13. Well to populate the form I replaced name with cite in all instances. Here is the whole part of processing the comments:
  14. OK. After figuring out why the cite was not populating, I changed the code to my Latest comments and in the articles-inner so that the author comes from $cite. Now for the tests I am logging as a different user (created one via the admin) and logged on as it to test the comments adding. Here is my comments adding form: <div id="respond" class="comment-respond form-border"> <h3 id="reply-title" class="comment-reply-title section-title"><br /> <i class="line"/>Leave a Reply <small class="pull-right"> <a rel="nofollow" id="cancel-comment-reply-link" href="<?=$page->url?>#respond" style="display:none;" class="btn btn-custom btn-xs">Cancel reply</a> </small> </h3> <form action="./" method="post" id="commentform" class="comment-form" novalidate=""> <div class="row"> <div class="col-md-12"> <div class="comment-form-author form-group"> <input id="cite" name="cite" type="hidden" class="form-control" value="<?=$user->name?>" size="30"> </div> <div class="comment-form-email form-group"> <input id="email" name="email" type="hidden" class="form-control" value="<?=$user->email?>" size="30"> </div> </div> <div class="col-md-12"> <div class="form-group"> <textarea id="text" name="text" class="form-control" cols="45" rows="8" aria-required="true"></textarea> </div> </div> </div> <p class="form-submit"> <input name="submit" type="submit" id="submit" class="submit btn btn-custom btn-lg" value="Share your opinion" /> </p> </form> </div> <? } ?> So I thought that $user->name would populate the name of the current user and if I am logged on as test, than the 'cite' would get populated with 'test' as author, but it shows admin on all comments in the DB and in the frontend.
  15. I got you, @adrian Well as far as the platform is intended to be used as an internal knowledge database, I would leave the registrations up to someone who will be charged for that, so I can eliminate the login-register forms etc. For sure I will have a look to see how it is done, but as of now it is all working. I noticed that in the comments form I was populating cite with $user->name but even if I post as a different user, all comment authors show admin instead of the user who posted the comment.
  16. Yes, it did populate the name and you were perfectly right (as always ) @adrian So now I will just remove the comments and test the cite for populating the official name of the user. How would you approach leaving a comment from non-registered user? Would you allow to post and then moderate or just offer to register and then comment?
  17. @adrian PR? I just remembered, that the form was actually having the cite but I did not realized that I modified it to name without considering the fact that the field is caled cite but not name. Let me change it and see if it would populate the cite...
  18. So I just checked and there is only one row in the DB that has in cite 'admin' . All the rest of the lines are empty, so it has to be something wrong with the form..
  19. Oh, now after reading what you say, I might have an issue with the form that adds the comments as I did decided to allow the commenting for the registered users only (intending to provide an option for switching in the admin later), so if the user is logged on, I populate the name in the form directly leaving only the comment block to have hold the text. The name and email are hidden, so if cite is populated through the name, then there has to be something wrong with the value... Here is my comments block code:
  20. @adrian Thanks very much for the shared info and the link. As far as I am just finding out some pieces of the way comments can be pulled through the API, I did not went that far yet to check in the DB but will do. In case the cite in database does not have any value, are there any settings to have the values added for the comments or do you know of any possible reason why 'cite' would stay empty? So far I tried to add a few users to the site and post a few comments and they show perfectly well so the code borrowed from FBG worked in my case but not using $cite. @fbg13 What you are saying seems the same as adrian. Let me check if the DB holds any cite values and see what could be the issue if not.
  21. @fbg13 I used parts of your code for my Latest commeents block and it works fine, but I have a little issue I am trying to figure out - when I try to echo $cite it shows nothing instead of showing the author. I made it work by using your way: $userID = $comment->created_users_id; $u = wire("pages")->get($userID); $name = ($u->displayName) ? $u->displayName : $u->name; However I am trying to figure out why $cite would be empty as it is much easier to use that instead of the extra lines. Any ideas or thoughts about possible reasons? My code sample is in this topic
  22. Ok, I got all that was needed for my design thanks to @fbg13 code for obtaining the user via the author id. I am attaching my complete code that shows the topic where the latest X-comments were added, shows the date of adding (based on the time format), shows the author of the comment and in my scenario shows the parent of the page (which in my case was used as category). On top of that it contains the anchors to the original comment so if clicked it would go straight to the content of the comment. To have the anchoring working, you need to assign the comment-## to the form (where ## is the ID of the comment). Thanks again to all who kindly shared their code that helped me get here.
  23. I had some progress in showing the proper comments topics and listing their titles promptly. To achieve that, I had to change the approach, so instead of first finding the pages that has some comments and then select the comments listed in them and limitting, I took the reverse approach by first searching for the comments and then match the pages whose id match with the comments id. Here is the example that worked like a charm and now I see all comments promptly even if they are posted in the same page or in a few repetetive ones: Now I need to figure out why on Earth the $cite returns empty string instead of showing the comments author and it would all be sorted. Special thanks to @Robin S and @adrian for sharing a way to query fields instead of pages. I should read a bit more about that ...
  24. So the example of Ryan worked but there are still some discrepancies to fix: 1. The pages query selects the 4 pages containing latest comments, but if a page has more than 1 comment, than this is where it gets confusing. As far as the comments query would repeat for every page that has comments, unless I select to show 1 comment per page (limit=1) I can't show just the 4 latest (e.g. if 4 pages hold 2 comments each, even though the limit in the comments query is 4, it will give 8 results). 2. For some strange reason, $cite does not show the user who have posted the comment but just an empty string. I tried to use $c->cite but that is empty too. Went to check in the field parameters for any reason why it would not show the author, but did not find anything. 3. While listing the comments in articles-inner as far as I use the API to show the results but not rendering those, how would I add the comments rating? So the fun part continues and was too early to celebrate
  25. @flydev Thank you very much for the link. I had to modify some parts for sure but it works now fine. Here is my code so far: <section id="section-lastest-responses" class="section"> <ul class="fa-ul"> <? $comment_pages = $pages->find("template!=news-inner, sort=-comments.created, limit=4"); foreach($comment_pages as $p) { $comments = $p->comments->find("created>=0, sort=-created, status=1, limit=1"); foreach($comments as $c) { ?> <li> <i class="fa-li fa fa-list-alt fa-fw text-muted"></i> <h3 class="h5"><a href="<?=$c->url?>"><?=$p->title?></a></h3> <small class="meta text-muted"> <span class="time"><i class="fa fa-clock-o fa-fw"></i> <?php echo wireRelativeTimeStr($c->created)?></span> <span class="category"><i class="fa fa-folder-open-o fa-fw"></i> <a href="#"><?=$p->parent->title?></a></span> </small> </li> <? } } ?> </ul> </section> Now to make it more fun and learn something extra, I decided to give the users a chance to click on the page title which would lead them straight to the comment. To achieve that, I changed the articles-inner template and added the comment id to every listed one. Then I am hyperlinking the page title: <a href="<?=$page->url . '#' . $c->id?>"> and it shows the link and the ID correctly, however the link has a backslash and it messes up the anchor (eg. http://domain.com/article/#id3) Am I missing something simple again in the big picture?
  • Create New...