Jump to content

The G

Members
  • Posts

    34
  • Joined

  • Last visited

Everything posted by The G

  1. My bad, i should've not added that render comment. Sure, I could check the fields to see if they are empty and a 404 is needed. The other languages don't need this check, though. They can be disabled and that's enough. My real question is about the editing interface: how can I hide the default language fields? Thanks for the link to Adrian's module. Unfortunately, as I said in the first post, I'd very much prefer not to separate the translation interface for all pages just because a few of them might not use a language. Also, it appears that the request Adrian made for hooking the Languages class remained unanswered and so, his module cannot currently select the supported languages - it's all or default only. IMO, the dificulty springs from the fact that the "name" and "title" mandatory fields are being used as translations. I'd rather duplicate "default" as English and treat "name" as an ID, but then again, Ryan knows much better than me.
  2. Hello everyone , I searched the forums, but could not find any simple way to take the default language out of one page (or a few pages), like this Homepage en page1 page2 de seite1 (page1 content translated in German) seite2 (page2 content translated in German) seite4 (only in German, no English version - this is what I don't know to do) The way it is now, the default language cannot be disabled, so "seite4" would have the English translation fields in the editing form and would render in the front end. I thought about creating a second English (en) language and hiding the default one, but it won't work because the way ProcessWire treats the "name" field. Another way would be separate trees for each language. That would work for languages with content that is different enough. But for one or a few pages that would not be translated to the default language, I would loose the integrated interface and big image would become more difficult to see. So I'd much prefer not to use it. The last way that crossed my mind was to modify the LanguageSupportPageNames module to update behind the curtain the default language with something while keeping it hidden. That's probably what I'll try given enough time. What do you say? What do I miss? LATER EDIT: I totally don't know any German, used it just as an example.
  3. Hi, I have a bunch of pages and I want to search for words or word parts in their "title" and "tags" field. The "tags" field is a textarea containing a comma separated list. It's a long story, I tried first using pages for tags, but text search was slow and I don't need them to have their own URL anyway, because I'm using query strings to bundle together all the search+filters+sort+pagination parts. Anyways... let me give an example: for instance somebody searches for "rome city". I need to get the results in this specific order: all full words in the title (i.e. both "rome" and "city in the title) all full words in the title or tags all word parts in the title (i.e. parts of both "rome" and "city in the title) all word parts in the title or tags Right now, I'm using merged PageArrays and it's quite a PITA: $results = new PageArray(); // this is computed, but to simplify I'm defining it here directly $searches = array ( 'title~=rome city', 'title|tags~=rome city', 'title%=rome,title%=city', 'title|tags%=rome,title|tags%=city', ); // the 'filter' part comes from a filter form via the whitelist // I'm leaving it in place to show that is precomputed // I took out the sorting and pagination parts $base_selector = array( 'base' => 'parent=1025', 'search' => '', 'filter' => implode(',', filterToSelector($filter)), ); foreach ($searches as $search_lap) { // $search_lap_selector is a temporary array of selectors for this round of search $search_lap_selector = $base_selector; // the current search is inserted into the selectors array $search_lap_selector['search'] = $search_lap; // this gets the ids of the pages already in $results PageArray $cids = array_flip($results->explode('id')); // implodeSelector implodes the selector parts in the correct order during conversion to and from the whitelist // this loop tests if $clip it's already present in $results PageArray and skips it if so, // to preserve the order // I tried with import, but every $results->import messes the results order foreach ($pages->find(implodeSelector($search_lap_selector)) as $clip) if (!isset($cids[$clip->id])) $results->add($clip); } This gets me the results, but, as I said, it's a PITA and somehow it doesn't look right. It would have been very nice if I could use selector groups and attach somehow the results count to the selector, so I could use the results count for sorting. Something like parent=1025, ('title~=rome city'), ('title|tags~=rome city'), ('title%=rome,title%=city'), ('title|tags%=rome,title|tags%=city'), sort=-title_full_matches_count, sort=-title_tags_full_matches_count, sort=-title_part_matches_count, sort=-title_tags_part_matches_count Does anything like this exists?
  4. Hi, Is there a way to use ProcessWire to convert ProcessWire selectors to SQL queries, i.e. like PageFinder does, but using the API?
  5. @diogo: nice idea to store the numbers in a page. Problem is, the numbers should reflect the actual selection count, so after selecting an option every count is different. And then there are the variants with two options selected and then with three... Seems like a lot. I'm sure your idea will haunt me, though. That clip has "artistic perspective". It also happens that is the default "no-video" clip . @horst: it is all very true. At the same time caching the markup obtained using SQL would be the same, only with a faster first access. Wouldn't it?
  6. Wow, thanks! Lots of good ideas! This forum is out of this world, I tell you. I replaced $pdostmt = wire('database')->prepare(' SELECT DISTINCT field_'.$dbtable.'.data as value, field_title.data as label, COUNT(*) as count FROM field_'.$dbtable.' LEFT JOIN field_title ON (field_title.pages_id = field_'.$dbtable.'.data) GROUP BY field_'.$dbtable.'.data '); $pdostmt->execute(); while ($row = $pdostmt->fetch(PDO::FETCH_ASSOC)) $filter_options[$criterion][] = array( 'name' => $row['name'], 'label' => $row['label'], 'count' => $row['count'] ); with $values = wire('pages')->find('parent=/search/'.$criterion); foreach ($values as $value) $filter_options[$criterion][] = array( 'name' => $value->name, 'label' => $value->title, 'count' => wire('pages')->count('parent=1020,'.$criterion.'='.$value), ); where $criterion is from a 4 fields array, and 1020 is the video clips container id. I like that the synthax is much cleaner and I can further glue selectors to the initial selector, But it works slower, as in 0.6 seconds slower with 4 fields and 20k video clips. It was surely expected and I think that the delay will increase linearly along with the video clips count. So I'll stay with the SQL version, unless there's possible to further optimize the API way. Thank you.
  7. Using find() without limit on a large number of pages wil eat all memory and bring your site down sooner or later, depending on your server configuration. Actually, I need to get all unique values from each field. Yes, I need the count for each value, but I need the values first.
  8. Thanks for your answer. I realize I should have given more information. The fields are video clip parameters, like format and length. I made the format a Page field and the length (duration) an integer field. All fields are included in a single template, so I already know the template. I want to make a search filter with every clip parameter as an option, each one displaying its video clips count, like this: Problem is, there are more than 20000 video clips and potentially many more, so I cannot do find() without limit. Right now I'm using SELECT DISTINCT `pages`.`name`, COUNT(*) FROM `field_format` LEFT JOIN `pages` ON (`field_format`.`data` = `pages`.`id`) GROUP BY `pages`.`name1 for Page fields and SELECT DISTINCT `data` as name, COUNT(*) as count FROM `field_length` GROUP BY name for scalar fields. I was wondering if there's some ProcessWire API magic for this.
  9. Hi, What's the processwirish way of doing: SELECT DISTINCT `pages`.`name`, COUNT(*) FROM `field_myfield` LEFT JOIN `pages` ON (`field_myfield`.`data` = `pages`.`id`) GROUP BY `pages`.`name` ?
×
×
  • Create New...