-
Posts
198 -
Joined
-
Last visited
Everything posted by Zahari M.
-
Hi Guys With all the awesome help some of you guys have been giving me.... let me write you a short audio story in return.... seeing as I can't write anything useful about PHP as all you regular guys here are mega hero level and me is just a rank amateur... But many of us do use headphones and I think I've found a real bargain gem! I was asked to help a lady friend select a vacuum cleaner the other day here in Kuala Lumpur at a very large electronics and home appliances retail store. Whilst waiting for her to preselect her vacuum cleaner, I noticed that they had a lot of these mannequin heads just beside the laptops section. As it turned out, they had about 20 heads there and each of them had a pair of headphones on them. I wasn't too excited as they all looked to be plugged in to the display table via a coiled cable.... usually they have crap music fed thru everything A closer examination however revealed that many of these headphones that had leads attached to them were not actually connected to any device. They were coiled umbilical cords used to prevent what the Australians call a "Five Finger Discount" from happening... I guess the idea here was that you BYOD, bring your own device.... presumably a tablet, a music source like an ipod or a mobile phone. In my case... I had my trusty iPhone 4S that I bought a couple of years ago ready n handy with a few well recorded jazz albums that I am readily familiar with. The headphones here ranged in price from about 20 USD for a budget set of Philiips headphones up to the most expensive pair there which were a set of higher end AKG's that would cost around 600 USD. Just slightly below the AKGs were a lot of mid-high end Sony Pro's. And so.... since it was early in the morning, and there were not many people there, it was my good fortune that no sales people were "bugging me". I was left all to myself! Basically I got to listen to just about every bloody pair of headphones there! And then go back to the next pair. And then back again!! I must have spent a good 45 minutes trying them all out! The results of these comparisons were quite interesting to me and I think I have found a cheap but extremely useful pair of headphones. I subsequently went online and ordered 3 pairs! One for my dad. One for me. One for my dads friend. They should arrive at my dads place in a few days. I will reveal more physical information when they arrive. Hopefully they will be identical to what was seen and heard in the shop! Unfortunately my MBA is running out of batteries and so I will have to continue this story tomorrow. Stay tuned! Cheers guys
-
How to get the first image of a repeater from another page?
Zahari M. replied to Zahari M.'s topic in General Support
Hi Adrian! Thanks for catching the $fields bit! Now I know! I did mention that it was a single image field. And so as you point out this image field was set to "1". And this in turn was creating the error. As I desire my repeater to use an image field set to "1", the loop and counter does exactly what I need. Phew! So I guess it might be best to think of it that ->first() is indeed available for us in repeaters... just as long as the image field is not set to "1"... Thanks so much again! Cheers! -
How to get the first image of a repeater from another page?
Zahari M. replied to Zahari M.'s topic in General Support
Hi Adrian Tried what you suggested but not much luck..... My earlier examples were named with conceptual variables . My actual variables are as below and I am omitting the child pages loops: foreach ($entry->media_repeater as $fields) { $img = $fields->repeater_image->first()->url; $content .= "<img src='{$img}' >"; } I believe the code above reflects the spirit and intent of your example, yet I end up with this error: Exception: Method Pageimage::first does not exist or is not callable in this context I've been juggling and trying to use ->first() all day and had come across this error before. Anyways... it's probably me not doing something right. But at least I worked out how to use a counter to get done what I needed. This is the first counter I have worked on / created so kinda thrilled I figured it out. Thanks again so much for looking!! Cheers -
How to get the first image of a repeater from another page?
Zahari M. replied to Zahari M.'s topic in General Support
Hi Adrian Ah! Good to know. I will give it a try and see! What I ended up doing was modifying the loop I referred to earlier such that it iterates through the repeater and finds the first populated image field. This is what my solution looks like thus far: if ($entry->media_repeater) { // Check to see if there is an actual repeater $i = 0; foreach ($entry->media_repeater as $fields) { if ($fields->repeater_image) { $i++; if ( $i == 1 ) { $img = $fields->repeater_image; $content .= "<div class='img-featured'>"; $content .= "<img class='img-style2' src='{$img->url}' alt='{$img->description}' title='{$img->description}'>"; $content .= "</div>"; } } } } I will try out your approach and see. Always learning! Thanks again. Cheers! -
Hi Vineet Most welcome! I switched over to Siteground a couple of months ago with their Grow Big account and like it very much so far! So I hear ya! Hi Craig! Thanks for the Digital Ocean link. Just out of curiosity, any hosting providers or recommendations that you feel get the security aspects right n tight? Cheers guys
-
How to get the first image of a repeater from another page?
Zahari M. replied to Zahari M.'s topic in General Support
Hey DaveP Thanks for chiming in. Much appreciated. After trying many permutations, in the end, it doesn't look like image->first() is usable with repeaters. And so by referring to the thread I linked to earlier, I adopted the loop and counter approach and that gets me my first image! Thanks again Cheers -
Hi Guys! Hope you can help! I have a repeater. Lets call it repeater_a. repeater_a has some fields attached to it. It has one image field called image_1. This is set to be a single image field. It has two text fields, text_a and text_b. In use, one entry of this repeater may have an image and one text field, another entry may not have an image but may have say 2 text fields... This repeater is not for a photo gallery or meta data. Think of it as ingredients of a recipe! The ingredients may include an entry that might have a picture. Now to add some further complication / clarification to the desired usage.. the pages that this repeater appear on are effectively child pages of a parent. So on the parent page, we wish to loop thru all the child pages and extract the first repeater image that appears (if any) for each child page. Conceptually I'm doing this: foreach ($childpages as $childpage) { foreach ($childpage->repeater_a->image_1->first() as $img) { echo $img; } } And Im ending up with this error: Error: Call to a member function first() on a non-object (line 50 of /Applications/MAMP/htdocs This question may been asked before here, but it was suggested that the usage there wasnt quite applicable to repeaters and their wasn't quite a clear cut answer to the problem! Any suggestions what Im doing wrong / how to do it right would be very much appreciated! Cheers guys!
-
Hi Vineet Just passing some random thoughts along... I once signed up with Linode just to have a look see. I too am a real novice when it comes to server administration and wanted to learn more. The plus point with Linode is that they have great documentation that can really help you along. That's great! Since integrity of data is important to you, I recall reading that Linode was hacked once. I recall that some people were very upset about this as they claimed that Linode tried to conceal the fact that they were hacked. Whatever the truth is there, I suggest that you at least look into that story and make your own judgement as to how secure your data would be with them. I had a look at their forums once and was saddened to see that the spirit there is much unlike that here in the ProcessWire forum. In fact I would say that the ProcessWire forum is an amazing world class showcase of what a forum should be. In Linode land forums I saw some very reasonable questions asked and they were greeted by such sarcasm from the smarts there. If you want to sign up for something affordable to learn server skills check out https://digitalocean.com/ I highly recommend having a play with Digital Ocean. Their "recipes" as in how tos are getting better all the time! Last year I attended a talk by AWS here in Malaysia. They are a very security conscious outfit indeed. For example all the engineers who came there to talk about AWS, they themselves don't know where their data centers exact locations are. Much there operates on a strictly need to know basis. When asked how to get started, what one of their engineers told me to do was to look for someone appropriate on elance.com and hire them to set things up for you or at least guide you. This way the entry barrier of complexity can be overcome... and possibly you can get him to be system admin as well? All just rambling thoughts for you mate!
-
Hi Guys.. Started cleaning up my Mac and thought I would have a look at MAMP and see if there was an update. Looks like there is a whole new version out! New price is 39 Euro. For most of us here, I suspect, the upgrade from Pro 2.x costs 19 Euro Just sharing... Cheers
-
Module: Video embed for YouTube/Vimeo (TextformatterVideoEmbed)
Zahari M. replied to ryan's topic in Modules/Plugins
Hi Martijn Thanks for that! Much appreciated! Cheers -
Module: Video embed for YouTube/Vimeo (TextformatterVideoEmbed)
Zahari M. replied to ryan's topic in Modules/Plugins
Hi Guys! A question for you gents... Is it possible to modify the module such that it automatically adds &rel=0 to all our YouTube video urls that we enter? Been trying to plug it in into various parts of the module but I can't seem to get it to work. It would save having to type in $rel=0 every single time I add a video. Cheers guys! -
How do we auto increment our title and name fields?
Zahari M. replied to Zahari M.'s topic in API & Templates
Hi horst Thanks for the great advice, replies and the code example too! I shall dig into it and study it! Thanks again renobird. Cheers guys! -
How do we auto increment our title and name fields?
Zahari M. replied to Zahari M.'s topic in API & Templates
Hi horst I did not forget. I simply did not know! Thanks for that! I shall look up typecasting in this context to see how to better code my inputs... Cheers! -
How do we auto increment our title and name fields?
Zahari M. replied to Zahari M.'s topic in API & Templates
Hi Adrian Never too late to chime in. And you know I always appreciate your insights! That module you mentioned does a very interesting thing. I have made a mental note to have a play with it later on when I have finished some other things. Indeed I was wondering to myself just 2 days ago how could we resolve a page by it's id. Looks like you've solved that one! Yay! Ok guys... thanks to renobirds suggestions and Joss's sterling wiki pages on the url segments system along with a good cup of coffee, I created this snippet which I fully understand... // URL SEGEMENTS SECTION: // As we are only using 1 URL segment, let's display a 404 if there's more than 1 URL segment. if($input->urlSegment2) throw new Wire404Exception(); // This enables video pages to be resolved by appending the video id to this url: www.site.com/videos/ if($input->urlSegment1){ $page = $pages->get("video_id={$input->urlSegment1}"); // In case there is no such video id, let's display a 404. if(!$page->id) throw new Wire404Exception(); } That and turning on URL segments is all I had to do. These URL segments are bloody brilliant!!!! So, for now rainbird, i thank you for helping me make / discovering a fundamentaly large architectural change to the way I shall be adding videos in to the system. I would however, be interested in knowing, if anyone could share, how we could get a field that we created to auto increment. In the case here, I could do what Joss suggested earlier, and use the page id as the video id. That could be done programatically and the more I think about it, the more I like the idea! Thanks Joss! But for acedemic purposes, lets say i am starting from scratch, or that I have a field that is assigning all sorts of things and information to a "serial number" that increments. So there might be a need to have a field in a template that can likewise auto increment whenever we create a new page using that template. Any suggestions anyone how to actually code this facility in? Thanks again guys!! -
How do we auto increment our title and name fields?
Zahari M. replied to Zahari M.'s topic in API & Templates
Hi Joss Thanks so much for for looking and commenting. I did a search and the wiki pages you did on url segments are fantastic Joss! Awesome stuff! Using the page ID is a good idea too Joss. As for the SEO aspect, as mentioned, the idea is that this video page isn't the page that is meant to be publicly consumed. The "flow" I desire Joss is that I do a video and store it on a page as an "assett". The videos are hosted externally, so all this page is really doing is holding all the various bits of data / metadata required to display the video and mark it up with schema.org properties for video objects. The articles that are written on my site are the ones where seo will be considered and these articles will pull the video in along with it's markup via a page reference field. The situation or need where these video pages would be deleted is extremely unlikely more like non-existent. I would just unpublish it. Why I want numerical id's for these video pages titles is simple. For specific situations where specific people want or need to see just the video, I can just say to people over the phone, go to mysite.com/videos/33 or whatever the number/s is/are. I want to spend as little time on the phone as possible and avoid spelling ambiguities etc! Hi renobird I think your idea of using url segments here was a great idea renobird! This way the title of the page can also be used as the name of the video, and one can get to it numerically via the number / url segment as you proposed. Yay! I do have one question though... if we use a video_id field as you have suggested, is there a way to automate our video_id field such that we don't have to keep filling it in on each new video page? It's not a big deal, but it would be nice if we can get it automated Cheers guys! -
How do we auto increment our title and name fields?
Zahari M. replied to Zahari M.'s topic in API & Templates
Hi renobird I have no intention of deleting any of these video pages once they are created, so I am not too worried about that aspect. All that I foresee is unpublishing them or not ever calling on them via the page reference field. If anything, it makes me extend the question now, how do we auto increment and disable deleting! But thanks so much for your great suggestions. I have just about zero experience with URL segments. So I will have to ponder on this and work at it for a while and read up on them. Once I have done that I will try and implement your suggestions. Thanks renobird! -
How do we auto increment our title and name fields?
Zahari M. replied to Zahari M.'s topic in API & Templates
Hi Renobird Thanks for the reply and looking. Much appreciated! I was replying to Martijn when your reply came in, so things are a lil out of time sync! Anyhows, the gist of it is, I want to create a video child page whose url portion or in Wordpress speak, "slug", has a number. If it is done this way, someone can look at a very specific video by going to mysite.com/videos/33. The name and title of the child page also become the video id and part of the address. Thats one way to watch the video. But its not the way I want to steer things. The main idea is to create aricles that use a page reference field to select a video and pull them in to my articles and get people to watch the video from within the article. Makes sense? Cheers! -
How do we auto increment our title and name fields?
Zahari M. replied to Zahari M.'s topic in API & Templates
Hi Martijn! Thanks for the reply. And looking! All good questions that you ask Martijn! Well, I did not intend for them to get deleted. But if they did, I would like it to work kind of like how an auto increment works in mysql. So if we go by your example above, the new one will get number 6. In this case Martijn, these pages hold one video. The idea is that you do not view the video page directly, although you could if you went to www.mysitecom/videos/3. The idea is that an article will use the page reference field to retrieve video pages and display them within articles. Whilst it is not that hard to see what the last video page was numered and mentaly add one to our new page, it would be nice if the creation of a new video page would take care of this for us as I have enough seo fields to fill in already Hee hee! So thats why I was asking. If anything, I would just unpublish a video page but not delete it. So any suggestions most appreciated. And congrats on the new iMac! Cheers! -
Hi Guys! Hopefully someone can offer me some assistance with this as it involves, I suspect, hooks and I have no idea how to use them . This will be the first time I have come across the need! So, what I have done is I created a parent page called Videos. This Video parent will have children and each of these children will hold 1 video. So what I want to do is make the title and name for each child page an automatically incrementing number when you create and save a page. So the first few child pages for the Videos parent will be titled and named 1, then 2, then 3 and so it goes... Doing a search first before asking, I came across these 2 code snippet in a thread here by fellow member Macrura who offered this code: public function init() { $this->pages->addHookAfter('saveReady', $this, 'autoIncrememt'); } public function autoIncrement(HookEvent $event) { $page = $event->arguments[0]; if($page->template != 'someTemplate') return; // some logic here to count the existing pages of this template and then add 1 and set the value of your auto increment field to that value, if it is empty. } As I am not at all familiar with how to achieve what I am trying to do, I am not sure if the above sample code is the way to go towards solving my need. I also have no idea where the above code goes and what the variable $this is supposed to be!! Any help would be greatly appreciated. Cheers guys and thanks for looking!!
-
Hi horst Thanks for the kind words and interesting links! Much appreciated
-
Hi Adrian Thanks again. Yeah. ProcessWire is such immense fun! BTW, for anyone reading this in the future... just needed to change $pages->get to $pages->find This got me the pages that were using the video... foreach($pages->find("video_selector=$page->id") as $article){echo "<li>{$article->title}</li>";} Just as an aside Adrian, you might be interested in watching this video I did. Video is the next thing I need to practise on. Once I have gotten my website sorted, I can spend some more time working on taking videos. The concept here is mix still photos with video clips. Totally unscripted and on the fly.... Why watch it? 2 reasons. Nice car. Shot with a handphone and the first video on it at that. https://www.youtube.com/watch?v=gYM8cPQRE8k My sites really coming along well. Can't wait to add your awesome video thumbs module in soon. All hail Adrian!!!! Cheers guys Oh! I didnt realise the video will show up here. I didnt mean to spam the site. Just thought it would show up as a link
-
Hi Adrian Very appreciative for your looking at this Before your last reply, your previous one gave me the hint I needed.... Thanks to you it dawned on me that on say video page id = 3, I could select for pages that have a video selection field whose id = 3. This would tell me which page or pages have "used" or "contain" this video. And in your latest reply you have shown me how to do it!! Thank you thank you! :) So my problem is solved. BUT.... Just for discussions sake now.... as there is no problem anymore... My understanding was that pageStack could be used to end up to do exactly what you have suggested above, i.e. I assumed that it could be used to generate the list of article page/s that were rendering a particular video page. So, I thought that pageStack was an alternative way of generating the very list that your code above would generate. I did not think of doing it the way you suggested earlier. But I'm glad you showed me it as I can see that that concept is a great one! I guess I made a wrong assumption here about pageStack. But all is not lost. pageStack has come in useful today! In my case, I've been using template classes within template files to enable me to reference external markup files to sort of lay things out in my own (amateurish) MVC layout.... Thanks to pageStack I can now get away with using one video markup file for the two cases its needed. On the article page we just get the central portion of the markup that deals with displaying the video, and on the video page, we can add our header markup and with the code you gave me, the markup where the video is being used Something like this // In Video Template // We use pageStack here to test if the video is being rendered via its template video or in an article page. if (!count($options['pageStack'])) { $page->set('requester', 't_Video'); // this will resolve on video template pages only, not article pages. } // In External Video Markup File if ($page->requester == "t_Video") { // Displayed only if we are looking at it on one of our video pages along with it's native t_Video template. All basic stuff for you guys Im sure... Big step for me thou... Anyways thanks Adrian and Soma!
-
Hi Adrian Thanks for your reply. Much appreciated. So I have a video template. So lets say I am viewing a page using this template. I would see a video. What I am after is that underneath the video it would say.... this video is used by article/3, article/100 etc. I would like to know which article page rendered my video page There was a thread where someone asked something similar.... http://processwire.com/talk/topic/3660-what-page-was-the-caller-of-render/ In this topic fellow member wanze said this: I guess this references a post by Ryan here: http://processwire.com/talk/topic/3145-multiple-views-for-templates/page-2 In it Ryan says... So Adrian, I thought, I guess mistakenly? that I could use pageStack in my video template to see which pages were rendering it... Does it make sense what I'm trying to do? Cheers
-
Hi Soma & Adrian Thanks so much for your replies Ok guys.... thats fixed the error! Now that I have done this, what I see happening is this... On my video page, I see the video On the article page, I see the article, the video and the page that requested the video. I want to see the page that requested the video on the video page. But instead it is showing it on the article page which is kinda pointless!! Any ideas how to display this information on the video page? Cheers!!!
-
Hi Adrian and Soma Thanks for the replies. Still not having much luck.. but I'm not very good at this at all... Anyhow guys.... For fear of any scoping related issues, I have cleaned up my video template, and inserted all my html markup for the video directly inside the video template. As you suggested Adrian, I added this to my video template: $requesters = $options['pagestack']; $out .= "<ul>"; foreach ($requesters as $requestee) {$out .= "<li><a href='{$requestee->url}'>{$requestee->title}</a></li>";} $out .= "</ul>"; What happens now when I view the article containing the video, or go to the video page directly, I get this error: Notice: Undefined index: pagestack in /Applications/MAMP/htdocs/test-site.dev/site/templates/t_Video.php on line 66 Warning: Invalid argument supplied for foreach() in /Applications/MAMP/htdocs/blog-starter.dev/site/templates/t_Video.php on line 69 Any ideas what it is that I am doing wrong? Cheers guys!