Marty Walker
Members-
Posts
633 -
Joined
-
Last visited
-
Days Won
3
Everything posted by Marty Walker
-
Everything in the body field where I'm putting the YouTube link is getting completely replaced by the iframe code. eg: text text text text youtube link text text text text <?php if(strpos($page->body, '<p>https://www.youtube.com') !== false) { $replacement = '<iframe width="480" height="360" src="https://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>'; $page->body = preg_replace('#<p>.*https://www.youtube.com/watch\?v=(\w{11}).*</p>#is', $replacement, $page->body);
-
Thanks so much Soma, Is there a reason why it replaces the entire body field? Regards Marty
-
The iframe code (preferable) that Youtube likes contains this style url: https://www.youtube.com/embed/rEKDj1OOkhI <iframe width="480" height="360" src="https://www.youtube.com/embed/rEKDj1OOkhI?rel=0" frameborder="0" allowfullscreen></iframe> But the easiest URL for a client to copy in is from the browser url area which would be: So I need a way to go from: https://www.youtube.com/watch?v=rEKDj1OOkhI to <iframe width="480" height="360" src="https://www.youtube.com/embed/rEKDj1OOkhI?rel=0" frameborder="0" allowfullscreen></iframe> Regards Marty
-
Module want: iPhone image uploader
Marty Walker replied to Svet's topic in Module/Plugin Development
I might be wrong but I don't think mobile Safari even allows it. -
Thank Ryan. I reckon it's nearly there. I think Google needs a different url: value="https://www.youtube.com/v/OVb6auDGo7E" If I use your code it gives me: value="https://www.youtube.com/watch?v=OVb6auDGo7E" I understand regex but not how it works. Any help re-wrangling this would be great. Regards Marty
-
Ah ok. I must admit this is the first time I've used the image description option.
-
I'm not sure if this is a bug or it's something else I've done, but I can't seem to remove an image description. I can alter the text but not completely delete it. Regards Martin
-
Thanks Antti. That makes sense. I just wanted to check. Regards Martin
-
I've tried this tag approach with absolutely no luck. Here's the tag I'm using: youtube:https://www.youtube.com/watch?v=rEKDj1OOkhI ...and my code. Is it my URL that's the issue? Regards Martin <? if(strpos($page->body, '<p>youtube:') !== false) { $replacement = '<object width="420" height="315"><param name="movie" value="$1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="$1" type="application/x-shockwave-flash" width="420" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>'; $page->body = preg_replace('{^<p>youtube:\s*(http://[^\s<]+)\s*</p>\s*$}m', $replacement, $page->body); } echo $page->body;
-
Great updates Antti. This is looking better than I ever expected. I did notice one thing when I was playing with it today. If I change the size on a preset it 'forgets' the previously generated thumbs and just reverts to an autocrop. Is that the intended behavior? Regards Marty
-
Will do. Actually I can't see those directories in the zip I've downloaded from github. The tar.gz download is fine though. Edit: Must be me. Both downloads have everything now. I'm going mad slowly. Regards Martin
-
Hi, I'm upgrading a site that's already running PW2.1 (non-RC) with the latest version from github. All I'm copying over are the following: wire directory, index.php and .htaccess file. I get the follow error whenever I try to view the site or login to the admin. I'm a bit stumped. Call to a member function execute() on a non-object (line 181 of /home/clients/public_html/site/index.php) Regards Martin
-
The easy way is usually my way. Thank you!
-
Hi, I know questions about TinyMCE come up a bit but I'm really stumped on how to be able to insert tables (shudder) into. Preferably without modifying the core setup. Regards Martin
-
Thanks Ryan that did the trick. I initially imported the pages via the Import Pages from CSV module. The About Us was the only part that didn't need reordering.
-
This is my original setup with includes: http://pastie.org/2723342 and without: http://pastie.org/2723358 I'm going to sleep on this one. Regards Marty
-
Beats me. If use just that code in the template it works fine. If I include all my other code the order chops and changes. BUT if I put all my code into one file as opposed to using <?php include('file.inc'); it all works fine. Strangely that subnavigation part of my code isn't an include.
-
The last few nav items down the left side, when clicked, it seems to change the order of the list. I've left the sort in the admin blank (manual). As I understood it if I don't use a field it just uses the order it appears in the admin list. Regards Marty
-
Hi, I'm use the code below to generate sub-navigation across some pages in my site. Each page uses the same template. As I click on each item in the list it generates the sort order is totally different each time. I've tried clearing the browser cache as well as clearing the PW cache to no effect. Stumped. Regards Marty <?php if($page->path != '/' && $page->rootParent->numChildren > 0) { echo "<ul class='subnav'>"; foreach($page->rootParent->children("sort=sort") as $child) { $class = $page === $child ? " class='current'" : ''; echo "<li$class><a href='{$child->url}'>{$child->title}</a></li>"; } echo "</ul>"; } ?>
-
Thanks so very much. I'm learning all the time with this great system and the generous help of folk like yourself. Regards Martin
-
Thanks Adam, That mostly works but I think I have an issue where I'm calling the image with: {$newsthumb->url} How would I alternate that with my fallback image? Regards Martin
-
Hi everyone, I've got a news section setup on a site in development. I want to pull the most recent three news items onto the home page. All good except for a small image issue. I have an image field in the news entry and below I'm calling the first one there for the thumbnail. What I'm stuck with is how to skip/ignore that instruction if there's no image. Most of the time there will be an image but I want to cover myself in case there's not. Regards Martin <?php $today = time(); $news = $pages->get("/news-and-events/")->find("limit=3, template=news-entry, sort=-publish_date, publish_date<$today"); foreach($news as $newsitem) { $newsimage = $newsitem->images->first(); if(!$newsimage) continue; // NOT SURE WHAT TO DO HERE $newsthumb = $newsimage->size(80,80); if(!$newsthumb) continue; // NOT SURE WHAT TO DO HERE echo "<dl class='clearfix'> <dt><a href='{$newsitem->url}'>{$newsitem->title}</a></dt> <dd class='image'><img src='{$newsthumb->url}' alt='{$newsitem->title}' width='80' height='80' /></dd> <dd>{$newsitem->summary}</dd> </dl>"; }
-
Thanks Ryan. I'll give that a go.
-
Never mind I got it: <?php if($page->related_pages != '')...
-
Hi, I've setup a related pages type field using ASMselect. It all works fine, the problem as per usual is my code (which mostly works): <?php if($page->related_pages) { echo "<h2>Related pages:</h2><ul>"; foreach($page->related_pages as $related_page) { echo "<li>{$related_page->title}</li>"; } echo "</ul>"; } The only issue I have is that if I don't select any related pages my H2 still appears. Regards Martin