-
Posts
196 -
Joined
-
Last visited
-
Days Won
1
Everything posted by thomas
-
Hello, i need to import a large number of articles from an old site into my PW project. So I wrote an import script which gets the data and for each row, creates a new page in PW and inserts it. So far, so easy. Problems arise because the old DB is latin-1 encoded and I keep getting strange results which are probably due to character encoding. $con = mysql_connect("localhost","yes","also"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_set_charset("latin1", $con); mysql_select_db("mtb", $con); $result = mysql_query('SELECT * FROM stuff'); while($row = mysql_fetch_array($result)) { $new = new Page(); $new->of(false); $new->template = wire('templates')->get('article'); $new->parent = wire('pages')->get('/news/'); $name = wire('sanitizer')->pageName(utf8_encode($row['HEADLINE'])); [*]$new_name = $name; $i = 1; while(isset($found{$new_name})) { error_log('DOPPLER! '.$new_name); $new_name = $name.'-'.$i; $i++; } $found{$new_name} = 1; } Even though I check for double page names, I keep getting the 'Duplicate entry' error. I also tried while(wire('pages')->get("name=$new_name,template=article")->id) {} to find duplicates but it stops with 'Duplicate entry' at a different data set ...I'm confused ... can anyone help? Thanks, thomas
-
Hi Soma, I just included your module in a page i'm working on, which already has over 400 videos complete with tags imported from the old site. It works great! I only changed the SQL query to "ORDER BY score DESC, modified, ASC" since that makes more sense in my case. Thanks for your work! - thomas
-
Cool apeisa, not sure what went wrong the first time but this works great! Now I've got the next problem (it never stops, does it?) http://processwire.com/talk/topic/1730-find-on-my-own-little-pagearray/
-
Hello, I have a function that creates a PageArray, throws a bunch of pages into it and returns it. Now I'd like to use all the PageArray methids on it but for some reason, everything after the first selector is ignored. The function: function getRelated($pageTags,$template,$limit=1000) { $pages = wire('pages'); foreach($pageTags as $tags) { $tag = wire('sanitizer')->selectorValue($tags->title); if($template) $templateQ = ",template=$template"; $related_pages = $pages->find("tags.title=$tag,id!=".wire('page')->id.$templateQ); foreach($related_pages as $related) { $related_id[$related->id]++; } } $rp = new PageArray(); foreach($related_id as $key => $val) if($tmp++ < $limit) { $rel_page = $pages->get($key); $rel_page->rank = $related_id[$key]; $rp->add($rel_page); } return $rp; } How I'd like to use it: $rel = getRelated($page->tags); $start = $input->urlSegment1 | 0; $related = $rel->find("sort=-rank,sort=-created,start=$start,limit=3"); This returns all the elements in $rel, sorted by rank, everything else is ignored. Is this a bug I built or a bug I found? Thanks, thomas
-
Hi apeisa, that's great. I also played around with this and return a PageArray now. I also tried to use the "weight" as a temporary field in my PageArray so I can sort by weight (like $related->find("sort=weight,sort=-created,limit=3")) but I couldn't get the temporary field to work. $rp = new PageArray(); foreach($related_id as $key => $val) if($tmp++ < $limit) { $rp->add($pages->get($key)); } Does anyone know a way to add a temporary field to each page I add to the PageArray $rp, which I can use to sort after I return $rp? Thanks, thomas
-
Hi, I'm gonna try and build an ajax powered comments system and was planning to build the whole thing on a one comment == one page basis. The comment page having a textfield for the actual comment, a page field with the user page of the commenter (it will require registration) and a page field for the page that was commented on. Since Ryan's comments module uses simple DB entries I was wondering if this is a good plan and what the benefits of not having one page per comment are? Will I experience problems if a million people comment stuff on my site? Thanks for hints an ideas! thomas
-
Hi Marc, I used output buffering to avoid echo lines. This way I can include a bunch of reaccuring html snippets (news.inc, videos.inc ...) which are almost straight HTML (with little <?=$something;?> in it) and put it all into the $page->body variable. At the end, I include main.php where $page->body displays the page content. I found the code a lot easier to read this way.
-
Hi everyone, I refused to switch to another CMS for many years. I worked with a Perl based self-made CMS that produced no markup and provided the basic tools to fill templates with life. After being pointed to PW by a friend I finally made the switch since our CMS is dated and needs to much work to keep at a reasonable level (UTF8 support among things). PW is what we wanted our CMS to be! So I just released my first PW project into the wild: http://bmxrider.de I quickly found myself at home in PW since the workflow is just the one I was used to. I could never make myself use webforms to edit templates or even have my stylesheets in a DB. I used an approach similar to Ryan's described here: http://processwire.c...legate-approach , with a little modification to keep the amount of PHP in my templates to a minimum. My "home" template looks like this: <?php include('./tools.inc'); ob_start(); $news = $pages->find("parent=/news/,sort=-created,limit=3"); $videos = $pages->find("parent=/video/,sort=-created,limit=3"); $aktuelles = $pages->find("parent=/news/|/magazine/|/video/|/termine/,id!=$news|$videos,sort=-created,limit=5,"); include('./news.inc'); ?> <div id="content-sidebar"> <div id="content-left"> <?php include('./videos.inc');?> <?php include('./aktuelles.inc'); ?> </div> <?php include('./sidebar.inc');?> </div> <? $page->body = ob_get_clean(); include('./main.php'); ?> I'm already working on the next PW project and hope to switch all of our company's sites better sooner than later. Thanks for a great product and community! thomas Edit: I forgot to mention the PW credit: http://bmxrider.de/impressum/ ... and also forgot to mention that I my only problem with PW is that it's PHP based. Perl is just much more fun! But I guess I'll get over that ...
-
Not sure what I changed but it works now! Only setTrackChanges produces wild results. Maybe it is because I don't really understand it ...? if($input->post->submit_save) { $edit->setTrackChanges(); $form->processInput($input->post); foreach($form->children() as $feld) { $edit->set($feld->name, $feld->value); } $edit->save(); foreach(array_unique($edit->getChanges()) as $change) { $session->message(sprintf($this->_('Change: %s'), $change)); } When I trackChanges on $edit (which is the page that's being edited) I get loads of message but never one of a field that was actually changed. If I trackChanges on $form, I don't get any messages at all. I guess it has to do with the order but I just can't seem to get it right ... Thanks for you help Ryan! -thomas
-
I generally try to use as little echo lines as possible. My code will be more like this <ul> <?php foreach($some as $else): ?> <li><?=$else;?></li> <?php endforeach;?> </ul> that way i don't have to worry about indention ...
-
Thanks for the info. I cranked up the memory limit to 2GB and uploaded 300MB videos on my localhost but wasn't sure if that's a route worth going on a production server. I'll probably just use SWFUpload from the old site.
-
Actually it is, because I want to restrict the frontend form to registered users with a certain role anyway. Any idea why the whole select and save works, as well as creating a new page, but creating one and then saving with it selected fails? Thanks, thomas
-
Hello, since I almost finished my first processwire project I am somewhat tempted to rebuild other sites that need a relaunch anyway. One of which is a video site where selected people can upload videos which are transcoded on the server into different formats (m4v,webm). This site is build in symfony 1.4 and since every little change always takes me ages to commit, I would very much like to rebuild in PW. One of my first questions for this project is if the inputfieldFile Ajax upload would be suitable for large video uploads up to 1GB or if I should rather use SWFUpload like the old site does ...? Does anyone here have any experience with those kind of uploads? Thanks, thomas
-
Thanks Ryan, my form works so far, the only thing missing is "create page" in the InputfieldPageAutocomplete.module. Adding existing pages works fine, but creating one and adding it throws this: Error Exception: Unknown Selector operator: '' -- was your selector value properly escaped? (in /wire/core/Selectors.php line 165) #0 /wire/core/Selectors.php(190): Selectors->create('', '', '-1') #1 /wire/core/Selectors.php(63): Selectors->extractString(-1) #2 /wire/core/Pages.php(132): Selectors->__construct(-1) #3 [internal function]: Pages->___find(-1, Array) #4 /wire/core/Wire.php(269): call_user_func_array(Array, Array) #5 /wire/core/Wire.php(229): Wire->runHooks('find', Array) #6 /wire/core/Pages.php(202): Wire->__call('find', Array) #7 /wire/core/Pages.php(202): Pages->find(-1, Array) #8 /wire/core/Pages.php(217): Pages->findOne(-1) #9 /wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.module(78): Pages->get(-1) #10 [internal function]: Inputf The same field works fine in admin. Any hints?
-
Hello everyone, Interesting thread! I am trying the same thing as Diogo but I need one file upload to work ... I'm getting this error Error Call to a member function path() on a non-object (line 90 of /wire/modules/Fieldtype/FieldtypeFile.module) Can someone help me make this FieldtypeFile work outside of the admin? Thanks, thomas Edit: I almost got it. /wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module holds all the secrets
-
Cheers Pete, that pretty much what I'm going for now. I use the ID from the network as unique identifier and password and generate a username that I query from the DB as soon as someone returns. It works great with Google already, now I need to squeeze Facebook in there as well. Ryan, thanks for tips! It's amazing how many ways there are in PW to achieve a task. I need individual accounts though, since I need to give at least two different roles to people and I want them to be able to update their profile. Thanks guys! thomas
-
Cheers SiNNuT, I've got the OAuth part figured out. Especially the 9lessons page helped. Now I try to find a way to connect it to PW users. Right now I tend to - set a username (generated by displayname on G+ or FB) and the ID as password. Then if someone returns to the site, look for the username to the G+ Id in the DB and log him in with that ... Sorry for the messy posts, it's hard to switch between PHP and English ... thomas
-
Hello, I want to build a site where people can *only* login with Google and/or Facebook (no registration possible). When someone connects with G+|FB I'd like to check if the ID is present in my Userlist and if not, create a new user with all the data I can get. Now I'm asking myself (and you) how I can log the user into PW, since I won't have a password and the username they got on FB|G+ might even change. I need to find those accounts by the FB|G+ ID. I thought either to create a new user with username/pass = G+|FB-ID and a field stating if it's G+ or FB. The other way would be to have a way to select and login a user via a unique ID field, but i can't find something like a "loginByCondition" method in PW. So I guess my questions are: -is there a way to login users other than user/pass? - which way would you suggest to build a system like that? My problem with the "user and pass == G+|FB-ID"-approach is that it smells like dirty hack and I couldn't, for instance, connect my own admin account with FB or G+ to make it work in front- and backend. Any help and thoughts are appreciated! Thanks, thomas
-
Thanks Soma!
-
Hello, still trying to understand everything ... I have an array of page IDs, now I want to push the pages with those IDs into a wireArray to use the PW methods on it, like limit and sort. How can I create a new wireArray to hold those pages? I tried $rp = $pages->makeNew(); but get an error ("Error Exception: Method Pages::makeNew does not exist or is not callable in this context") Thanks for help! thomas
-
A different way of using templates / delegate approach
thomas replied to Soma's topic in API & Templates
Cheers, I'll take another look at your approach then -
A different way of using templates / delegate approach
thomas replied to Soma's topic in API & Templates
Ryan's, where the dynamic content is definded in the page's template before callling the page structure (main.php). -
A different way of using templates / delegate approach
thomas replied to Soma's topic in API & Templates
My question is how you deal with functions that are potentially needed in every single page on the site. Putting them into main.php doesn't work in this example, because those functions are needed in teaser.php, which is called before main.php. One way would of course be to put include('./functions.php') into every template but I was wondering if there's a way to specify a file that is automatically included into every template. -
A different way of using templates / delegate approach
thomas replied to Soma's topic in API & Templates
Thanks for the interesting thread. If you (like me) don't like to put markup into variables, you can use the output buffer to use cleaner include files: ob_start(); include('./teaser.php'); include('./pager.php'); $page->body = ob_get_clean(); include('./main.php'); That way your include files can be html with php elements and not $page->body="<p>something</p>" I have one question to the main.php approach, though: I have a bunch of functions that are used by several templates. With the head/foot method I would simply put them into head.inc and make them available to every page. Where do you put this when using a main.php? Would that be a module? Thanks, thomas -
Cheers slkwrm!