Jump to content

tinacious

Members
  • Posts

    82
  • Joined

  • Last visited

Posts posted by tinacious

  1. 12 hours ago, Robin S said:

    Assuming the "city" Page Reference field is in the "country" or "state" template, the selector string for selectable pages would be:

    
    
     

    Hi @Robin S thanks for your help. I've dumbed down the example since my initial example was difficult to understand. I'd actually be adding the Page Reference to a field on a repeater field on the city template.

    The city example may be a bit simple to illustrate what I'm trying to do. 

    I am trying to build dependencies with a legal document which has content types Article, Section, and ConfigurableField.

    • Article (page)
      • Section (page, child of either Article or Section to support infinite nesting of Section types)
        • ConfigurableField (repeater)
          • This has properties that can be configurable, e.g.
            • Field Name = short text
            • Field type = enum
            • Dependencies (Page Reference)
              • This is the field I'd like to say "get me any other ConfigurableField provided that it's in the same Article"

    In the first screenshot is the field type used for my dependencies field. It is of Input field type = Checkboxes

    In the second screenshot is the selector and template configuration. Currently I'm selecting any other repeater_configurable_field but I need to scope it to those only under the same Article (article.php). Other than Home, Article is the root. 

    Would your suggestion work in this case? 

     

    Update: I have tried your suggestion where I reference the configurable field, e.g.

    template=configurable_field, has_parent=page.rootParent

    That doesn't work but I can link to a section:

    template=section, has_parent=page.rootParent

    My guess that this isn't working is because, even though repeaters have a page-related API, they aren't surfaced as pages consistently in the API. For example, they are only surfaced when using the Page Reference of Input type Checkbox, and are not for the ASM Selector or other page selector types. And it seems that there may not be support for querying for it amongst pages.

    I know I can access the repeaters in code, so I'm wondering if next I need to try a custom PHP-based selector rather than using a selector string.

     

    Update: I have also tried the PHP-based one and with the selector string suggested, though that selector string works for sections and in the UI, it doesn't work in ready.php with the same selector string:

    // Doesn't work even though this selector string works in the UI
    $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) {
      if($event->object->hasField == 'dependencies') {
        $event->return = $event->pages->find('template=section, has_parent=page.rootParent');
      }
    });
    
    
    // Doesn't work either but if the first one doesn't work, I wasn't expecting this one to work.
    $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) {
      if($event->object->hasField == 'dependencies') {
        $event->return = $event->pages->find('template=repeater_configurable_field, has_parent=page.rootParent');
      }
    });

     

    image.thumb.png.dce103a4d3847847b9d0753ecd90ceff.png

    277330189_Edit_Field__dependencies__localhost.thumb.png.c9f629aca3dc51861af4354c98e1fdfa.png

  2. Picture the following hierarchy:

    • Canada
      • British Columbia
        • Vancouver
      • Ontario
        • Toronto
      • Nova Scotia
        • Halifax
    • United States
      • California
        • Los Angeles
      • New York
        • New York City

    I used the word "page selector" but should've said "page reference."

    Consider that I am trying to make a page reference for a city, so it has the template type of city, but I want to restrict cities to cities within the same country.

    For example, I have a field on the city template that is called "similar city" but I only want to choose cities within the same country. I don't want the user to choose a city in a different country so I need to take the 2 following criteria into account:

    1. The template (city.php)
    2. The final parent Canada, if I'm trying to choose a Canadian city, or United States if I'm trying to choose an American city.

    So something like:

    $currentCountry = currentCity.getCountry();
    $allowedCities = currentCountry.getAllCities();

    Those allowedCities would be the ones I'd want to include in the Page Reference field.

    Essentially, I need to make a custom selector that has some knowledge about what the root parent (other than home) is and filter for cities within that parent.

    image.png

  3. Hello! It's been a while since I've done ProcessWire development, but I'm back (and quite rusty with it, and PHP). Forgive me if these questions have already been answered!

    I have a field called dependencies that I would like to list a list of other fields. So far, I've been able to accomplish this by using the Input Field Type = Checkboxes and the template of the repeater field.

    Let's say I have the following hierarchy:

    • Article (page)
      • Section (page)
        • Field (repeater field)
          • title
          • dependencies (PageArray)

    I have the following data:

    • Commercial (article)
      • Basic terms (section)
        • Parking included? (field in repeater field)
        • Parking spots (field in repeater field)
    • Residential (article)
      • Basic terms (section)
        • Parking included? (field in repeater field)
        • Parking spots (field in repeater field)

    I am using the page selector to represent a list of dependency fields. Currently, by using Checkboxes, I see all repeater fields in the app. I would like to limit it to all fields within the same parent article. For example, if I have 2 lease documents, they both have a section "Basic terms" and I would like to list "Parking included" as a dependency of "Parking spots." The UI is confusing if I see "Parking included?" twice with the checkbox UI. ASM Select, Page List Select, and Page Auto-complete do not expose repeater fields so I can't use those.

    So, the solution to my problem could be one of the 2 (or maybe you have a better idea):

    • The ability to expose repeater fields to ASM Select, Page List Select, and Page Auto-complete
    • The ability to make a custom selector to include all repeater fields within the same article (template = article)

    Thank you in advance for your help! ?

  4. Hello all. Thank you in advance for your help.

    I am making a bilingual website in French and English using ProcessWire. It's my first time doing a multi-language site.

    I am storing a date object with ProcessWire in the database using the date field and retrieving it in PHP. 

    I am detecting the language that the user is viewing the site in and then setting the PHP locale like this in a PHP object called $strings:

    setlocale(LC_ALL, ($is_english ? 'en_US' : 'fr_FR'));
    

    Then when I am getting the date, I am doing this:

    $formatted_date = strftime($strings['date_format'], $page->date);
    

    The characters with accents (like décembre) are getting mangled. Am I doing something wrong? I haven't been able to figure it out. When the client adds French characters in the TinyMCE or other fields, they are not mangled, which leads me to believe I may be doing something incorrectly with the above code.

    Is there an optimal way of retrieving dates in different languages for multi-lingual ProcessWire sites?

    Thanks!

    post-466-0-85370800-1416707891_thumb.png

  5. Hi all, I've had some issues during the migration process with using a remote database including login and performance issues. I was wondering if there were specific measures to take into account when using a remote database.

    My first issue is the performance. I noticed that now since I've been using a remote database that the site takes longer to load. Is there anything I can do to improve the site performance like cache the database or anything? Everything is very slow, especially in the admin pages when loading the pages list, editing an item, etc.

    My other issue was not being able to log in to the site. I would get the "Login failed" error and sometimes "This request was aborted because it appears to be forged."

    I have tried a number of suggestions I've found on the forums including making sure my assets folder has permissions 777, deleting the contents of /assets/sessions/, changing the session name to $config->sessionName = session_name(); or just commenting it out altogether. None of these worked.

    This was the line in my config.php that worked:

    $config->protectCSRF = false;
    

    With that suggestion also came the disclaimer that it may not be the best approach. I want to use best practices so would like to know what the best way for working with remote databases securely would be?

    Thanks for your help.

  6. Hi tina,

    Sorry for the limited answer - was in a hurry.

    Actually looking at this module a little more, I realize that I have never used the built-in render, but rather just used it as a way to enter addresses in the admin. I have been using Ryan's RCDmap class: http://processwire.com/talk/topic/690-map-marker-fieldtype/?p=10667

    Although I actually haven't hidden the poi in any PW sites yet, so I don't have a final code snippet for you. However, this is the code that I used on a mobile site I developed that made use of: https://code.google.com/p/jquery-ui-map/

    var myStyles =[
        {
            featureType: "poi",
            elementType: "labels",
            stylers: [
                  { visibility: "off" }
            ]
        }
    ];
    
    $('#map_canvas').gmap('option', 'styles', myStyles);
     

    I wouldn't necessarily recommend jquery-ui-map - I thought it might be worth trying, but mostly just seemed to add another layer of complexity. I think I would stick with the standard gmaps api.

    Here is a relevant POI link from google: https://developers.google.com/maps/documentation/javascript/reference#MapTypeStyleFeatureType

    Hope that helps.

    Thanks Adrian, I decided to just use the Google Maps API and the values created by the ProcessWire module to assist in that. I used the visibility: off for the POI and that worked. Thanks.

    • Like 1
  7. This config option should disable the POI for you:

     [ { featureType: "poi", elementType: "labels", stylers: [ { visibility: "off" } ] } ]
    

    Obviously this is not a module setting, but rather a setting you need to add to the javascript that loads the map on the frontend.

    Hope that helps.

    Thanks but this is the code I have:

    In the head:

    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
    

    And then in the body:

    <?php // Render the map
    
    				$map = $modules->get('MarkupGoogleMap');
    				echo $map->render($page, 'address_map', array('type' => 'ROADMAP'));
    			?>
    

    Where would I put the code you suggest?

  8. I've actually not seen businesses show up on the map before? :) At least, we aren't specifying any options to make it do so. Can you post a screenshot, just in case I'm misunderstanding what you are talking about? I'm wondering if it might somehow be picking up some google-specific setting associated with your Google account. 

    I'm attaching a screenshot. Timeless Nails, Tango Palace, etc. I hear they're called POI (points of interest) but I am unsure how to add any settings for disabling these with the module. Thanks!

    post-466-0-17219900-1384292206_thumb.png

  9. This is an amazing module! I've only scraped the surface but just from reading through this thread it seems very powerful.

    I was wondering if there was a quick way to hide the businesses that show up on the map. I'm using this to make a restaurant site and I'm trying to avoid having other restaurants (but businesses in general) pop up on the map.

  10. Hi everyone,
     
    I made a walkthrough of a web app I built using ProcessWire for the Tenova Group mining company.
     
    They needed an intranet application to keep track of their daily plant operations. I designed and developed a ProcessWire solution that would allow registered employees at Tenova HYL to record events regularly in an event log. 
     
    Storing all of the events in this manner would allow registered users to find the events they're looking for using keyword search, date filters as well as filters based on other criteria.
     
    Each event also allows the user to upload supporting files for download, such as Word documents and PDFs, as well as upload relevant images to be displayed in a modal window.
     
    A high-performing, powerful solution using the ProcessWire CMS.
     
    Read about the project here in my portfolio.

    See the video here: 

    Tina Holly

    tinaciousdesign.com

    post-466-0-26150000-1379548056_thumb.png

    • Like 15
  11. Hey Ryan,

    Thanks for your help. Here's the HTML I'm using. The text inputs are jQuery UI datepickers.

    <div class="filters">
    	
    	<h3><a href="#">Date Filters</a></h3>
    
    	<form action="<?php echo $page->url?>" method="post">
    		<div class="inputs">
    			<label for="date_start">From</label>
    			<input type="text" id="date_start" value="">
    			<label for="date_end">To</label>
    			<input type="text" id="date_end" value="">
    			<input type="submit" value="Filter Date" class="button">
    		</div>
    	</form>
    </div>
    
    <?php
    
    if($input->post->date_start) {
    	$startdate = strtotime($input->post->date_start);
    	if($startdate) $selector = "date_start>=$startdate";
    }
    if($input->post->date_end) {
    	$enddate = strtotime($input->post->date_end);
    	if($enddate) $selector = "date_end<=$enddate";
    }
    

    I'm not doing this correctly I'm sure, I don't have much experience with creating forms in ProcessWire. Visual attached.

    Hopefully it doesn't add confusion but the HTML id's for the inputs are the same as their field name in ProcessWire.

    post-466-0-56032000-1365597713_thumb.png

  12. Hi everyone, I'm wondering what the best way to sort a page by date is. I have a few pages that render a list of pages based on specific criteria, e.g. template. I want to provide 2 date pickers on each of those pages to allow users to search by date range on that specific page. I'm wondering what the best way to go about it is.

    The date has formatting attached to it. I'm wondering if I should use the unformatted version instead of the formatted one. Would this make it easier to work with in this situation?

    I was thinking of using jQuery UI datepickers and a button to submit the form and apply the date range filter to the results that are rendered on the page. 

    if($page->id == 1) {
        $events = $pages->get("name=event")->children;
    } else if($page->name == 'users') {
        $events = $pages->find("created_users_id=$username, template=log-item");
    } else {
        $sort_type = $page->template;
        $events = $pages->find("$sort_type=$page");
    }
    if(count($events)) { 
    	foreach($events as $event) { 
    		// ... 
    	} 
    }
    

    The date I will be working with has been stored in the $page->date_start field. Currently it is formatted using ProcessWire's options.

    I'm wondering what the best way to tie date filtering functionality into the above query would be, if even possible, and if not, which way should I go about doing it?

    Thanks!

  13. Hi Tina,

    I've done something similair for a project.

    You need an autoload module which executes a code like this:

    class YourAutoloadModule extends WireData implements Module {
    
    //...
    
    public function init() {
      
      if ($this->user->hasRole('yourFrontendRole') {
        $this->addHookBefore('ProcessHome::execute', $this, 'redirectToFrontend');
      }
      
    }
    
    public function redirectToFrontend(HookEvent $event) {
      $frontend = $pages->get('yourPage');
      $this->session->redirect($frontend->url);
    }
    
    }
    

    Hey, I changed "yourFrontendRole" to an actual role but it doesn't work. I get a server error when using that. It's detecting the role because superuser has no problems logging in but upon logging in with my 'standard' role I've created, it causes a 500 error. I think it's having trouble at the $this->session->redirect part.

    This is what mine looks like (it's not working)

    class LoginRedirect extends WireData implements Module {
    	public static function getModuleInfo() {
    		return array(
    			'title' => 'Login Redirect', 
    			'version' => 1, 
    			'summary' => '',
    			'author' => '',
    			'singular' => true, 
    			'autoload' => true, 
    			);
    	}
    
    	public function init() {
    		if($this->user->hasRole("standard")) {
    			$this->addHookBefore('ProcessHome::execute', $this, 'redirectToFrontend');
    		}
    	}
    
    	public function redirectToFrontend(HookEvent $event) {
    		$this->$session->redirect($pages->get(1)->url);
    	}
    }
    
  14. Hi all, I would like to redirect the session after successful login for a specific role. I want to keep a specific role in the front-end most of the time and upon successful login, would like to redirect them to the front page instead of the Pages section in the back-end. How would you suggest hooking into the login function and redirecting that role upon successful login? I know I'll need to use $session->redirect(). Thanks!

  15. Ok so I gave it a shot with creating a module by altering Ryan's code you linked to and this seems to be working so far (I think). Here's the module using that code teppo linked to, slightly modified to match my requirements:

    <?php
    /**
     * Edit Yours Only
     *
     */
    class EditYoursOnly extends WireData implements Module {
    	public static function getModuleInfo() {
    		return array(
    			'title' => 'Edit Yours Only', 
    			'version' => 1, 
    			'summary' => 'Custom module to allow users only to edit pages they created. Applies to role \'standard\'',
    			'author' => 'Christina Holly, TinaciousDesign.com',
    			'singular' => true, 
    			'autoload' => true, 
    			);
    	}
    
    	public function init() {
    	    if($this->user->hasRole("standard")) $this->addHookAfter("Page::editable", $this, 'editable'); 
    	}
    
    	public function editable(HookEvent $event) {
    	    // abort if no access
    	    if(!$event->return) return; 
    	    $page = $event->object; 
    	    // criteria required in order to edit
    	    if($this->user->name !== $page->createdUser->name) $event->return = false; 
    	}
    }
    

    If anyone sees any problems that this could cause, please let me know. So far it appears to be working as I want it but I haven't tested it thoroughly.

    Thanks!

    • Like 6
×
×
  • Create New...