Jump to content

AlexV

Members
  • Posts

    21
  • Joined

  • Last visited

Profile Information

  • Gender
    Male
  • Location
    Moscow

AlexV's Achievements

Jr. Member

Jr. Member (3/6)

1

Reputation

  1. Thanks for the answer. I forgot that Processwire means — easy! Fields are really rewritten at an import! And this is great news for me. Thank you Ryan again!
  2. Hi guys! How can I rewrite the data in the field in this way? My site has a field "body" with data. I want to specify in file(csv) page name and new data of the field "body". How do I delete the old value of the field "body" and write a new data?
  3. Thanks Ryan! I understood your idea. I yet don't know as it to realize, but I will try )
  4. Thanks for the reply Ryan! In the second case, I used a «text» field, so that did not work. I changed it on the field «float» and added your code, thank you, it works! I will describe in more detail the first question. I have two checkboxes and code which I specified above. Now when I choose one checkbox search works well. When I choose two checkboxes, search shows that one is chosen only. How it is possible to change a code that search was on two values (which I select checkboxes)?
  5. There are still questions of search. While I can't answer them itself. First question. Now I have two checkbox, it work by a principle "or", in what case they will work as "and". Now the code in the search template looks like this: $name = $sanitizer->pageName($input->get->type_of_oper); $man = $pages->get("parent=/business_type/, name=$name"); if($man->id) { $input->whitelist('type_of_oper', $man->name); $selector .= "type_of_operation=$man, "; } Second question. In the search form has two text fields "from" and "before". How to realize search for them? Сode search form: <label for="square">Square</label> <input type="text" name="squareMin" value="<?php if($input->whitelist->squareMin) echo htmlentities($input->whitelist->squareMin, ENT_QUOTES, "UTF-8"); ?>" /> <input type="text" name="squareMax" value="<?php if($input->whitelist->squareMax) echo htmlentities($input->whitelist->squareMax, ENT_QUOTES, "UTF-8"); ?>" /> Code that I tried to use in search template, but it does not work: $valueMin = $sanitizer->selectorValue($input->get->squareMin); $valueMax = $sanitizer->selectorValue($input->get->squareMax); $selector .= "object_square>=$valueMin, object_square<=$valueMax, ";
  6. Thanks Ryan, this is what was needed!
  7. Ryan, when I remove the code /*if($input->get->distr) { $district = $pages->get("/district/" . $sanitizer->pageName($input->get->distr)); if($district) { $selector .= "parent=$district, "; $input->whitelist('distr', $distr->name); } }*/ rest of the code begins to work. When I turn on, I get: parent=/direction/city/, parent=1253, There are no results matching the query I can guess why. Here is the hierarchy of pages: |- direction | | | |- city | |- object 1 (object has a Pagefield named «district», in which selected pages «district 1 and so on») | |- object 2 | |- and so on | |- district | |- district 1 | |- district 2 I want to get a list of objects from the section «city» criteria «district». How can I do? upd: I found the solution, it was too easy, instead of the «parent» it is necessary to use a «field» $selector .= "parent district_location=$district, "; But now another question, not displayed «whitelist» ) In what may be the reason? upd2: I found the solution works until I add another criterion in the search, for example: if($input->get->type_of_oper) { $type_of_oper = $pages->get("/business_type/" . $sanitizer->pageName($input->get->type_of_oper)); if($type_of_oper) { $selector .= "type_of_operation=$type_of_oper, "; $input->whitelist('type_of_oper', $type_of_oper->name); } } after adding it, I get: parent=/direction/city/, district_location=, type_of_operation=1021, how to avoid it?
  8. Thanks for the tip, Soma! I often there look. My experience does not allow to use it so effectively, so as not to ask questions to more experienced users
  9. Thanks for the reply Ryan and code, it clarifies some things ) Question that I asked - I solved (so delete it) and walked right up to the search, the results of which I can not get it. Form code I've described above, in a search template I use the following code (searching only two fields participate now): include("./header.inc"); $selector = 'parent=/direction/city/, '; if($input->get->id) { $value = $sanitizer->selectorValue($input->get->id); $selector .= "object_id~=$value, "; $input->whitelist('id', $value); } if($input->get->distr) { $distr = $pages->get("/district/" . $sanitizer->pageName($input->get->distr)); if($distr) { $selector .= "parent=$distr, "; $input->whitelist('distr', $distr->name); } } $objects = $pages->find($selector); $count = count($objects); echo "<h2>" . htmlentities($selector, ENT_QUOTES, "UTF-8") . "</h2>"; if($count) { echo "<h2>Found pages: $count</h2>"; foreach($objects as $obj) { echo "<div><a href='{$obj->url}'>{$obj->title}</a></div>" ; } } else echo "<h2>There are no results matching the query</h2>"; include("./footer.inc"); I made them for example, but they do not work, and the reason that I can not yet understand. upd: Slowly I begin to understand the structure. It appears in the search involved a hierarchy of pages. On an example of skyscrapers it: cities -> city -> object -> its properties (height, floors, year). What if such structure isn't present and my objects aren't enclosed, and are parallel? What role does this value $selector = 'parent=/direction/city/, '; ? Differently: how add in search of architects of skyscrapers? )
  10. Thanks Ryan and Diogo for the clarification! Now, the function of line $p->setOutputFormatting(false); became clear to me.
  11. Thank you again, Diogo! That's right, I want to add a few pages in Pagefield "subway_station". $value — I took out the one you specify an example. I thought that is possible to define a set of pages in shorter way, to list id or title.
  12. Thank you Diogo! After your edition the code works! «Green» and «orange» — two pages that had to be chosen in the Pagefield. For an example: page title «green», and its address "/subway_station/sub_st_0111/", but how to specify the «orange» (with address "/subway_station/sub_st_0222/"), I didn't know, therefore in a code only one, «green». Tell please, what syntax of record $value. It can be "title" or "id" or "address" of several pages?
  13. Hi guys! I want to import into multiple pages at once the same value of the field, which is Pagefield. I make a selection of pages, and how to specify the page in Pagefield do not know. Likely this question already rose, but at a forum I didn't find the answer. Example: Pagefield is called «subway_station» in it I have to choose two out of a hundred pages, called «green» and «orange», as it be? foreach($pages->get("/district/")->find("district_region=UZAO") as $p) { echo "<a href='{$p->url}'>{$p->title}</a> " ; $p->subway_station->add("/subway_station/sub_st_0111/"); // $p->save(); }
  14. Hi! Search realization is impossible to me, prompt as it is possible to solve it if the form with selectors at me looks so: <form id="city_obj_search" method="get" action="<?php echo $config->urls->root?>city_obj_search/"> <ul> <li> <?php foreach($pages->get("/business_type/")->children() as $type_of_oper) { $checked = $type_of_oper->name == $input->whitelist->type_of_oper ? " checked='checked' " : ''; echo "<div> <label> <input$checked type='checkbox' name='type_of_oper' value='{$type_of_oper->name}'>{$type_of_oper->title} </label> </div>" ; } ?> </li> <li> <label for="district_location">District</label> <select id="district_location" name="distr"> <option value="any">Any</option> <?php foreach($pages->get("/district/")->children() as $distr) { $selected = $distr->name == $input->whitelist->distr ? " selected='selected' " : ''; echo "<option$selected value='{$distr->name}'>{$distr->title}</option>"; } ?> </select> </li> <li> <label for="subway_station">Subway station</label> <select id="subway_station" name="subway"> <option value="any">Any</option> <?php foreach($pages->get("/subway_station/")->children() as $subway) { $selected = $subway->name == $input->whitelist->subway ? " selected='selected' " : ''; echo "<option$selected value='{$subway->name}'>{$subway->title}</option>"; } ?> </select> </li> <li> <label for="object_cost_ru">Cost in ru</label> <select id="object_cost_ru" name="costru"> <option value="any">Any</option> <?php foreach(array('30000-50000', '50000-100000', '100000-250000', '250000-500000', '500000-1000000', '1000000+') as $costru) { $selected = $costru == $input->whitelist->costru ? " selected='selected'" : ''; echo "<option$selected value='$costru'>$costru руб.</option>"; } ?> </select> </li> <li> <label for="object_cost_dol">Cost in dollars</label> <select id="object_cost_dol" name="costdol"> <option value="any">Any</option> <?php foreach(array('1000-3000', '3000-10000', '10000-20000', '20000-30000', '30000+') as $costdol) { $selected = $costdol == $input->whitelist->costdol ? " selected='selected'" : ''; echo "<option$selected value='$costdol'>$costdol $</option>"; } ?> </select> </li> <li> <label for='search_id'>ID</label> <input type="text" placeholder="00000" name="id" id="search_id" value="<?php if($input->whitelist->id) echo htmlentities($input->whitelist->id, ENT_QUOTES); ?>" /> </li> <li> <input type="submit" id="search_submit" name="submit" value="Find!"> </li> </ul> </form> I wish that this request would be processed the search page «city_obj_search/», but the information from the forum (http://processwire.c...op-down-search/) that I use does not help me either an error or an empty result. Help to understand, please.
  15. Thanks Soma, I received a reply. I used in the 'title' rus characters and did not use multi-language support, so when exporting 'title' field was obtained «as a blank».
×
×
  • Create New...