Jump to content

thomas

Members
  • Posts

    196
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by thomas

  1. Hi Soma, "views"is a simple table which writes a page id whenever someone watches a video on my site. I expect this to get rather large so I didn't want it to be PW pages. The query returns an array of page id's and works fine. As I said, everything works fine until I add "category.id" to filter (or "find", I tried both) ... I'll try leaving out the .id ... Thanks, thomas
  2. Hello, I have a fieldtype Page named 'category' in my pages. I want to find pages from several categories like this: $teaser=$pages->find("template=video,category.id=17|19|23,sort=-created"); This works great. Now I try the same thing on "my own" pageArray: $sql = "select distinct video from views order by created desc"; $result = wire('db')->query($sql); $bw = new PageArray; while($row = $result->fetch_array()) { if($video = $pages->get($row['video'])->id) $bw->add($video); } $teaser=$bw->filter("template=video,category.id=17|19|23"); ... now $teaser contains nothing. It works well when I leave out "category.id=[...]" in the filter ... Can anyone help? Thanks, thomas
  3. Hello, I was wondering if it was possible to hook before PageImages url is given, so I can provide a default image if an image is missing? I have about a hundred cases where I need to check for count($page->image), so I thought maybe a module could do this? Thanks! thomas
  4. Thanks a lot for the answers! Soma, that is just what I was looking for. I have a bunch of modules already, and this will help me put them in context! - thomas
  5. Hello everyone, my oop knowledge is pretty limited so please don't stone me for the forthcoming question: I have a rather large project which I'm moving from symfony 1.4 to PW (finally). I'm rebuilding most of the functions in modules with Page hooks, which at one point (now) leads to a naming problem. LIke a countMedia() method can be neccessary for many different contextes. - Is there a way to give a module it's own class name? So I can use $channel->countMedia(), $tag->countMedia(), both referring to different modules? - how do YOU deal with a large set of user functions that are needed in many different templates? Thanks, thomas
  6. Cheers for the answer, Soma! I'm talking about a user profile on the frontend, no PW user, so yours is pretty much the way I did it know. The whole question was more of a thought experiment if I could use PW to handle the include() decision for me.
  7. Thanks for your answers, I achieved want I wanted with hooking before render, now I only need to figure out if this is actually a good idea. Instead of using a lot of if() or different include() I thought I could use a different template for the current page, depending on a condition. So I built a "profile" template and a "profile_edit". If someone accesses his profile ('/profile/my_fancy_user_name') the link to edit his own profile is ('/profile/my_fancy_user_name/edit') ... it works, but I already encountered the first drawback: the two templates need to have the same fields. So I might just go for the "include()" Sorry, I should stop typing while thinking ... t
  8. Hi, I'd like to have an "edit" option for pages in the frontend. I thought I could append an urlSegment to the page url and (instead of coding show and edit functions into one template) simply switch templates: if($input->urlSegments[1] == 'edit') $page->template=$templates->get('page_edit'); This code doesn't work ... Is this even possible or do I need to redirect or put all code in one template? Thanks! thomas
  9. It's working now ... I wasn't aware $event->return holds what the name implies Thanks!
  10. Got it. I'm slowly understanding the hooks
  11. Hello, I'm trying to build a very simple Translator Plugin and somehow managed to get what I want on a "simple" page, meaning one that's straight from the admin. Now I'm trying to build the same functionality into my overview pages. The idea is to put the language into the session and then use $page->body or $page->body_en (and a few other fields) accordingly. Is there a way I can hook into $pages->find, iterate over the array, swap the content of the containing pages and return the array? For style and comfort I'd like to do this in a module, so a hook is needed. I tried addHookAfter('Pages::find,'','') but could make no sense out of it. I hope my explanation makes sense. Thanks for any hints, thomas
  12. So far I never had problems with checking the url. But just noticed it also throws a warning so I'll just be strict from now on Thanks
  13. Alright. For some reason it all works if I put <?php if(count($user->image)>0):?> instead of <?php if($user->image->url):?> weird, but glad I found it ...
  14. Thanks for the hints. I actually check if the user exists, sorry for not posting it: if(!$profile->id) $session->redirect('/'); The thing I don't understand is: <h1 class="blue"><?=$profile->displayname;?></h1> <?php if($profile->image->url):?> <img src="<?=$profile->image->first()->size(100,100)->url;?>" style="float:left;margin-right:10px;"> <?php else:? This displays the displayname correctly and then exits with "Exception: Method Pageimage::first does not exist or is not callable in this context" even though I'm sure there is an image AND <?php if($profile->image->url):?> works on all other sites and occasions for me. Another mystery: If I go to the profile page without being logged into the admin, everything shows up fine. I open another tab, log into the admin, reload the profile page, and my profile image throws an error again. Confused ...
  15. Hello, I have a strange problem here. Long story: - I added an Image field to my user template - On my page I have a little login box in a sidebar, which is displayed whenever the current user isn't guest. It the checks if the user has an image uploaded: <?php if($user->image->url):?> <img src="<?=$user->image->size(60,60)->url;?>" style="float:right;"> <?php endif;?> This works. Now to the strange part: In the main content of the page I want to display a profile page for any givven user registered. I took this approach from Ryan's BlogProfile: $name = $sanitizer->pageName($input->urlSegment1); $profile = $users->get($name); <?php if($profile->image->url):?> <img src="<?=$profile->image->size(100,100)->url;?>" style="float:left;margin-right:10px;"> <?php endif;?> This is on the same page as the login box. Now I'm getting very strange results. Checking if a file is uploaded constantly fails, so I get errors when there's no image. It's hard to explain and my only two explanations are I'm either stupid or there's something I need to know about images in a user object, or getting info from $users. Sorry for the weak explanation, can someone help me out? Thanks, thomas
  16. Cool. I just updated and now it works. Cheers.
  17. Hm ... I remember trying it (that is "advanced", right?) but it didn't work for fieldtypes Pages and Image, which is what I needed. I'll try again, although on my sites unpublishing a page is better than publishing one without a teaser image, for instance. And as I said, my editors won't learn. Thanks! t
  18. Yeah, I thought about that but these people don't learn unless there's consequences. I did have to built a rather dirty hack to get through the "add page" dialogue, though. So my method isn't too sophisticated.
  19. I just built a module that adds a "addHookBefore('save' ...) Hook and the checks the inputs I want to be required. If the requirements aren't met, there's an error and I set $page->addStatus(Page::statusUnpublished); ... This seems to work great so far. Is there anything I'm missing? (since this method isn't mentioned here ...)
  20. Thanks Soma!
  21. Hello, This is a tiny thing that's easily changed but I thought I'll post it here anyways: I'm having a hard time explaining to the editors that clicking "view" in the backend while editing a page will pretty much delete all the changes made if you don't save the page first. It would be great if "view" opened the page in a new window or would save the changes first (while leaving unpublished). Thanks, thomas
  22. Thanks for the info, Ryan! This is a one time import but I'll need to do it for several sites so your tips are really appreciated.
  23. There's already a bunch defined in there even though I had no idea this existed. Cool. Since PW uses this to create new pages it is obvious why my script didn't catch some of the duplicates ...
  24. I have no idea what this even does but adding "Sanitizer::translate" to my $sanitizer call solved the problem ...
  25. I' m not really seeing big problems other than the duplicate error which keeps me from importing the whole DB. I just don't know how to catch it! Other than that, there's a few special characters gone missing (like „these quotes“) but I can live with that ...
×
×
  • Create New...