Jump to content

EyeDentify

Members
  • Posts

    160
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by EyeDentify

  1. Hello There fellow PW users. I have been racking my brain looking at this code for a while know and the solution probably is simple. But i need a fresch set of eyes on my problem. I have this code: <?PHP /* render siblings or not */ $sibItems = $page->siblings(); if(count($sibItems) > 0) { echo('<ul class="unstyled-list">'); echo('<li>Other post like this:</li>'); /* render the siblings if any, exclude current page */ foreach($page->siblings('limit=5', false) AS $sibling) { echo("<li><a href=\"{$sibling->url}\">{$sibling->title}</a></li>"); } echo('</ul>'); } ?> What i am trying to do is detect if there are any siblings to the current post, and if there are siblings then render them. If no siblings then not render. You get the picture. But at this point the IF statement is run no mather what i do. and this post i am testing on has no siblings. It is a lone child under another page so it should not have siblings. But the count() method gets a 1 integer anyway ? So what am i doing wrong here? I thought it should give me a 0 integer if there are no siblings. Maybe i have forgotten something. Thanks for all your help.
  2. Thank you all for your tips and answers. I think i might have explained things wrong. The only purpose i have is for me to have a way to organize things so its more clear. Like in my Editor or in my FTP client. Not that i wish to switch certain template files for specific templates and so on. Its purely a organization issue. But i thank you anyway. szabesz seems to come closest to what i was after. I will have a look.
  3. By the way, could you give an example of this "route.php" stuff you mentioned ?
  4. Hello LostKobrakai. Thank you for the fast answer. I will have to give this some thought how to go about it.
  5. Hello Fellow PW users and fans. I have a simple question that needs an answer. Have been working on a pretty complex site know for a while and lots of template files. So i was wondering if i could for sake of keeping everything organized could sort my template files in sub directorys and still have PW recognize these template files and find them when needed ? Or do i have to keep them all in the same "template" dir. I know how to use include() and all that. So thats not what i am after. Because i would like to distinguish my main template files and some that are experimental and possibly not going to be used in the finished site. And there getting to be alot of them at this point and at times a bit confusing to distinguish them. Well there you have it. thanks in advance.
  6. They should rename it so that its apparent that B as in Bold applies the <strong> tag. Cause for me i think tags like <b> and <strong>. Maybe this is why CK editor shuts down when i change that setting ?
  7. Hello. Thank you for your reply. I Rather use strong tag because its what should be used instead of B. But its no big deal, I have worked around it. I was just curios why CK editor would not work when i changed the mentioned setting.
  8. Hello everyone. I am back with a question thats come up lately when i was creating some new fields for a template of mine. The following happend. I created a new field of the "textarea" type and changed it to "CKeditor" on the Details tab under "inputfield type". So far so good. Everything working as expected when editing data on the page using the template wich the field was assigned to. But then i decided to get a little brave, so i went to edit the fields settings and under the "Input" tab i changed "Format tags" string to include the tag "strong". The Format tag field string before my change was: "p;h1;h2;h3;h4;h5;h6;pre;address" and after my change it was: "p;h1;h2;h3;h4;h5;h6;pre;address;strong" Now, after that change when i saved it and went back to editing the data on the page, the CK editor refused to show and there was only the fields label but just white space under it. If i go back and edit the field and the Format tags back to the default everything works again and the CK editor shows up when editing data. But if i change the Format tags it goes away. What i am doing wrong ?
  9. Oki Then i have my answer. I will have to rethink my solution and look at the referenced Ryan Solution wich seems good for my case. Thx Again LostKobrakai.
  10. Thx again. I will have a look at Ryans solution. It seems pretty straight forward to change for my needs. Though i was still curious if there is a strictly PW API way of doing this. if i could specify that i only want to return the "category" field from the pages i target with a selector and that would make it less expensive if i have alot of pages ? If not then i will look at Ryans code and come up with something on my own. I am not that worried about performence right know, but down the line maybe. Thanks again for all suggestions.
  11. Thank you for the post LostKobrakai The link about unique looks promising. But i am still going to first have to return all the records in the PageArray and then filter them with unique ? Is that not expensive when i have alot of pages in that array ?
  12. Hello Again friends. I was working on a new website and i had a mental block about a query i would like to do with the help of PW API. And then i could not figure out how to do this specific one. I know how to do it in MySQL for example: SELECT DISTINCT category FROM movies The purpose here is to get all the uniuqe categorys from those pages that are each one a movie title. Because there could be the same category string in more then one movie title. For example say: 1. Die Hard (category: Action) 2. Die Hard 2 (category: Action) 3. Die Hard 3 (category: Action) 4. Ghosts of Mars (category: Sci-fi) Then i would like to at the end of the query get back: 1. Action 2. Sci-Fi As uniqe categorys. And then make category links using those uniqe categorys wich is no problem either. But how do i perform the above MySQL query in PW API terms ? I Have gone through all Selector documentation and havent found something that directly represent what i want to do. And i know i could use the SQL class and methods, but i want to use PW API as much as possible to learn. I would like to not have to get all the movie title pages with regular PW API and then with some Array magic sort out the uniqe categorys if i could avoid it, cause i know this site will have alot of movies and tv series in the "database" in the future. So that could mean alot of memory usage. Or is my best bet to just have a "tree" structure of say: movies - Action -- Die Hard 1 -- Die Hard 2 -- Die Hard 3 - Sci-Fi -- Ghost of Mars And then say, use a text field on each title page that has the type of either "movie" or "tv series" for example ? Because i want to be able to sort distinguish between them later on. If anything is confusing about my question, just ask and i will try to clarify.
  13. Well it seems to work so far as i can tell. i Declear this solved. Will reopen if things changes.
  14. Quick update. I checked all the templates cache setting and it is not enabled so it can´t be the cache ? Maybe session related ?
  15. Thank you for all your tips. For some reason it now seems to be working. I am going to keep an eye on it. Could it be cache related and the cache was cleared after a while and now it works ?
  16. Hello all the nice PW people. I am trying to work out why the following code of my visit counter: <?PHP /* simple code for recording current page visit count to its visit_counter field of "integer" type. But only if the visitor is not currently logged in. */ if($user->isLoggedin()) { /* if the user is logged in do not count visits */ } else { /* if the user is NOT logged in and not counted */ /* turn of output formating so PW do not give an error when we change the value */ $page->of(false); /* increment the current integer plus one */ $page->visit_counter = $page->visit_counter + 1; /* save the visitor_counter field */ $page->save('visit_counter'); /* turn on output formating so PW work as it should */ $page->of(true); } ?> Do not work in my 3.0.8 installation of ProcessWire. It works in another website where i run 2.7.2 very well. The field name is visit_counter and the type is Integer. And the field is added to all the relevant templates. Also tested editing the field in a page via admin and that updates and works. But not via the API it seems. I include it at the top of my template files just under the BODY tag. Have i missed anything ? I am greatfull for all suggestions have gone a bit stir crazy trying to figure this out.
  17. You can create so to speak an empty template without an uploaded template file by going to the Admin > setup > templates > add And not choose a template file. Then a empty template is created unless you choose to have fields included from another template. You can use this template When creating pages just like templates with files connected to them. Hope it helps.
  18. Well thats my way of coding it's a mather of preference i guess.
  19. Ofcourse Your right.... How did i miss that ... guess sometimes you go blind.... Thank you pwired.
  20. Hello Everyone. I have previous posted a tutorial in the Tutorial section about a counter system for counting visits to a page in PW. The code works an all is fine and dandy. Now i am trying something fancy pants... and making the code count a visitor once per session. This seems however not be the case and the visit is counted again on every page load. I must have done something wrong somewhere. I maybe have gone a little blind looking at this code. Am i wrong in testing this code by: Login to admin Then visit the page Check if count goes up ? no it does not so that works. Log out from Admin then visit page again and reload a few times Once again log into admin, and yes... all the reloads are counted... damit. Is my session reset somehow from me logging in and out of admin ? Any pointers or tips would be helpfull. <?PHP /* simple code for recording current page visit count to its visit_counter field of "integer" type. But only if the visitor is not currently logged in. */ /* set a counter flag to use with the counter */ $session->set('visit_counter_flag', 0); if($user->isLoggedin()) { /* if the user is logged in */ } else { /* check if the flag is set to 1, if so then do not count the visit */ if($session->get('visit_counter_flag') === 0) { /* if the user is NOT logged in and not counted */ /* turn of output formating so PW do not give an error when we change the value */ $page->of(false); /* increment the current integer plus one */ $page->visit_counter++; /* save the visitor_counter field */ $page->save('visit_counter'); /* turn on output formating so PW work as it should */ $page->of(true); /* set a visit counter flag to 1 so next load do not count */ $session->set('visit_counter_flag', 1); } } ?> Thank you in advance.
  21. Thanks for reminding me. One could read about the various licenses here: http://flickity.metafizzy.co/#license
  22. Hello again. Thought i share my way of creating sliders in my ProcessWire websites, by using the images field type and some HTML, JavaScript, CSS and a pinch of love. Step One: Go to http://flickity.metafizzy.co/ and download Flickity slider. They also have a CDN option for thoose who prefere that. Also have the page handy cause it has alot of usefull info for configuring the slider and such. Note: In my example i use jQuery to initialize Flickity but you can use it without, see the website for more info. So you need to load jQuery before flickity in the header section for my example to work. Step Two: Here is an example of how you could write some code and HTML for your template file where the slider should render. This code assumes your images field is named images. <div class="slider-container"> <?PHP /* check if there is any images to display */ if(count($page->images) > 0) { /* render out the images and resize to 700 pixel width */ foreach($page->images AS $key => $image) { echo('<img src="' . $image->width(700)->url . '" class="slider-container-item" alt="' . $image->description . '">'); } } else { echo('<p>Houston we have a problem...there are no images to see here...</p>'); } ?> </div> Also lets put together some simple CSS for our container and items. Alter it to your own needs and preference. For the Flickitys sliders default CSS and configuring see the website. .slider-container { position: relative; display: block; overflow: hidden; width: 100%; max-width: 700px; padding: 0; margin-bottom: 15px; clear: both; } .slider-container-item { position: relative; display: block; width: 100%; height: auto; max-width: 700px; } Step Three: Put the default CSS and also Flickitys JS files and load jQuery before Flickity in the header of your site so that flickity works as intended. Or use the CDN option mentioned on the flickity website. <link rel="stylesheet" href="/path/to/flickity.css" media="screen"> <script src="/path/to/jquery.js"></script> <script src="/path/to/flickity.pkgd.min.js"></script> Don´t forget to put the Flickity JavaScript initalization code at the bottom of the template file. For all the Options and configuration see the website: http://flickity.metafizzy.co/ In the example code below i use just a few of the many options. <script type="text/javascript"> /* initiate Flickity Slider JS */ $(document).ready(function(e){ $('.slider-container').flickity({ // options cellSelector: '.slider-container-item', cellAlign: 'center', imagesLoaded: true, percentPosition: true, contain: true }); }); </script> Note: This is my prefered way of doing it. But there are alternative ways to initialize Flickity if you read the info on the website. This should be enough to get you started. And with a little imagination i think you could see the potential. Good luck with all your Slider making dreams
  23. Hello Krlos. Welcome to PW community. I hope you will persist and learn PHP because its worth it and a wonderfull language once you get the hang of it. I would suggest you have a look at the: http://www.php.net and also another good source with alot of valuable info is: http://www.phptherightway.com/ PHP the Right Way might be tough to for beginners but they teach good concept and worth a read. Good luck and don´t be afraid to ask questions.
×
×
  • Create New...