fbg13

Updating modules

9 posts in this topic

Is it possible to update a module without it being in the module directory?

The same way that one in the module directory is.

Share this post


Link to post
Share on other sites

Not sure I follow...yes, you can update by:

  1. Pointing to a URL (e.g. GitHub download link to the module)
  2. Uploading from a local folder...

ProcessWire will then update it. Watch out for folder names though, sometimes the module can end up at 'ProcessMyModule' rather than 'MyModule'. In such cases you should get an error about 'cannot redeclare class...'

Share this post


Link to post
Share on other sites

Read this http://modules.processwire.com/export-json/

You have the option to change the following in your config.php

$config->moduleServiceURL = 'http://modules.processwire.com/export-json/';
$config->moduleServiceKey = (__NAMESPACE__ ? 'pw300' : 'pw280');

Example for a request
http://modules.processwire.com/export-json/FieldtypeSelectExtOption/?apikey=pw300

created from moduleServiceURL, ModuleClassName, moduleServiceKey (GET Parameter)

1 person likes this

Share this post


Link to post
Share on other sites

Yes for sure. Sorry for answering unclear. I just wanted to say that the information about the module version is pulled from the processwire modules directory by default.

You could add a hook before ProcessModule::executeEdit() and change this only if the classname of the event object matches your specific module.

Share this post


Link to post
Share on other sites

Thank you @kixe I managed to achieve what I need.

Any idea what the key (pw300/pw200) is doing?

For whoever is interested. In my module I added

public function init() {
	wire()->addHookBefore("ProcessModule::execute", $this, "changeModuleService");
}

public function changeModuleService(HookEvent $event) {
	if($_GET["update"] === "ModuleName") {
		wire("config")->moduleServiceURL = "http://domain.tld/";
		wire("config")->moduleServiceKey = (__NAMESPACE__ ? "pw300" : "pw280");
	}
}

And the module autoload property is set to "autoload" => "path=/admin/module/"

Now whenever the "check for updates" link is clicked it searches for a new version on domain.tld/ModuleName, this has to return a json similar to the one posted above.

2 people like this

Share this post


Link to post
Share on other sites

Just because it's Monday:

<?php

/**
 * ProcessWire module.
 *
 * Allow depending modules to be updated from non-standard repositories.
 *
 * In absence of this module, your module will continue to work but updates
 * will point at the regular repository. If you want to avoid that, add
 * a "requires" entry in your module
 *
 * To trigger the custom update routines, add an array "extendedUpdate" to
 * your getModuleInfo array. It can either contain a "url" entry with the
 * URL to the JSON data that describes the available update, or a "customMethod"
 * entry with the name of a public method in your module that returns that
 * URL.
 *
 * If you go the "url" way, the value there is run through wirePopulateStringTags.
 * You can add placeholders for all of the modules moduleInfo values, the module's
 * configuration values, the "moduleServiceKey" (PW base version, i.e. pw300, pw280 etc.)
 * and the module's name as, yeah, you guessed it, "name".
 *
 * If you use customMethod, it gets passed an associative array with all these values.
 *
 * A simple example for a module using custom updates:
 *
 * class TestModule extends WireData implements Module {
 * 	public static function getModuleInfo() {
 * 		return array(
 * 			"title"				=>	_("Test Module"),
 * 			"summary"			=>	_("Test for a module with a custom update location"),
 * 			"version"			=>	"0.0.1",
 * 			"requires"			=>	array("ModuleUpdateCustomUrl"),
 * 			"extendedUpdate"	=>	array(
 * 				"url"				=>	"https://bitpoet.ddns.net/update/{name}.json?apiVersion={moduleServiceKey}",
 *				// Alternative way to generate the URL through a method in your module:
 * 				//"customMethod"	=>	"generateUrl"
 * 			)
 * 		);
 * 	}
 * 	
 * 	public function generateUrl($data) {
 * 		return "https://bitpoet.ddns.net/update/" . $data['name'] . ".json?apiVersion=" . $data['moduleServiceKey'];
 * 	}
 * 	
 * }
 * 
 *
 * A somewhat minimal JSON example response for the test module above:
 * {
 *    "status":"success",
 *    "class_name":"TestModule",
 *    "module_version":"0.0.2",
 *    "authors":[
 *       {
 *          "title":"BitPoet"
 *       },
 *       {
 *          "title":"Anonymous"
 *       }
 *    ],
 *    "pw_versions":[
 *       {
 *          "name":"2.7"
 *       },
 *       {
 *          "name":"2.8"
 *       },
 *       {
 *          "name":"3.0"
 *       }
 *    ],
 *    "download_url":"https://bitpoet.ddns.net/update/TestModule_0.0.2.zip",
 *    "release_state":{
 *       "title":"Beta"
 *    },
 *    "summary":"Test for a module with a custom update location",
 *    "module_home":"https://bitpoet.ddns.org/modules/TestModule"
 * }
 *
 * For a complete example, see the live data from the official repo, e.g.
 * http://modules.processwire.com/export-json/Helloworld/?apikey=pw300
 *
 * The response must either return a property "success" with a true value
 * or populate an "error" property with a description of what went wrong.
 * 
 */


class ModuleUpdateCustomUrl extends WireData implements Module {
	public static function getModuleInfo() {
		return array(
			"title"			=>	_("Module Update from Custom Url"),
			"summary"		=>	_("Extension module that allows modules to be updated from non-standard repos."),
			"version"		=>	"0.0.4",
			"autoload"		=>	true,
		);
	}
	

	public function init() {
		$this->addHookBefore("ProcessModule::execute", $this, "hookProcessModuleExecute_customUpdate");
	}
	
	public function hookProcessModuleExecute_customUpdate(HookEvent $event) {
		if($this->input->get->update) {
			$name = $this->sanitizer->name($this->input->get->update); 
			$info = $this->modules->getModuleInfo($name);
			
			if(! $info["extendedUpdate"]) return;
			
			if(! isset($info["extendedUpdate"]["url"]) && !isset($info["extendedUpdate"]["customMethod"])) {
				$this->error($this->_('Neither URL nor custom method set in extendedUpdate configuration in module info'));
				return;
			}
			
			$event->return = $this->downloadDialog($name, $info);
			$event->replace = true;
		}
	}
	

	public function downloadDialog($name, $info) {
		$redirectURL = "./edit?name=$name";
		$className = $name; 
		
		$cfgdata = $this->modules->getModuleConfigData($name);
		$params = array_merge($info, $cfgdata);
		$params["moduleServiceKey"] = $this->wire('sanitizer')->name($this->wire('config')->moduleServiceKey);
		$params["name"] = $name;

		if(isset($info["extendedUpdate"]["customMethod"])) {
			$method = $info["extendedUpdate"]["customMethod"];
			$module = $this->modules->get($name);
			$url = $module->$method($params);
		} else {
			$url = trim(wirePopulateStringTags($info["extendedUpdate"]["url"], $params));
		}
		
		$http = $this->wire(new WireHttp());
		$data = $http->get($url); 
		
		if(empty($data)) {
			$this->error($this->_('Error retrieving data from web service URL') . ' - ' . $http->getError());
			return $this->session->redirect($redirectURL);
		}
		$data = json_decode($data, true); 
		if(empty($data)) {
			$this->error($this->_('Error decoding JSON from web service')); 
			return $this->session->redirect($redirectURL);
		}
		if($data['status'] !== 'success') {
			$this->error($this->_('Error reported by web service:') . ' ' . $this->wire('sanitizer')->entities($data['error']));
			return $this->session->redirect($redirectURL);	
		}
		
		$form = $this->buildDownloadConfirmForm($data);
		return $form->render(); 			
	}
	
	
	public function buildDownloadConfirmForm($data) {
		$warnings = array();
		$authors = '';
		
		foreach($data['authors'] as $author) $authors .= $author['title'] . ", ";
		$authors = rtrim($authors, ", ");

		$compat = '';
		$isCompat = false;
		$myVersion = substr($this->wire('config')->version, 0, 3);
		foreach($data['pw_versions'] as $v) {
			$compat .= $v['name'] . ", ";
			if(version_compare($v['name'], $myVersion) >= 0) $isCompat = true;
		}
		$compat = trim($compat, ", ");
		if(!$isCompat) $warnings[] = $this->_('This module does not indicate compatibility with this version of ProcessWire. It may still work, but you may want to check with the module author.');

		$form = $this->wire('modules')->get('InputfieldForm');
		$form->attr('action', './download/');
		$form->attr('method', 'post');
		$form->attr('id', 'ModuleInfo');
		$markup = $this->wire('modules')->get('InputfieldMarkup');
		$form->add($markup);
		
		$installed = $this->modules->isInstalled($data['class_name']) ? $this->modules->getModuleInfoVerbose($data['class_name']) : null;
	
		$moduleVersionNote = '';
		if($installed) {
			$installedVersion = $this->formatVersion($installed['version']); 
			if($installedVersion == $data['module_version']) {
				$note = $this->_('Current installed version is already up-to-date'); 
				$installedVersion .= ' - ' . $note;
				$this->message($note); 
				$this->session->redirect("./edit?name=$data[class_name]"); 
			} else {
				if(version_compare($installedVersion, $data['module_version']) < 0) {
					$this->message($this->_('An update to this module is available!')); 
				} else {
					$moduleVersionNote = " <span class='ui-state-error-text'>(" . $this->_('older than the one you already have installed!') . ")</span>";
				}
			}
		} else {
			$installedVersion = $this->_x('Not yet', 'install-table');
		}

		$table = $this->wire('modules')->get('MarkupAdminDataTable');
		$table->setEncodeEntities(false);
		$table->row(array($this->_x('Class', 'install-table'), $this->wire('sanitizer')->entities($data['class_name'])));
		$table->row(array($this->_x('Version', 'install-table'), $this->wire('sanitizer')->entities($data['module_version']) . $moduleVersionNote));
		$table->row(array($this->_x('Installed?', 'install-table'), $installedVersion)); 
		$table->row(array($this->_x('Authors', 'install-table'), $this->wire('sanitizer')->entities($authors)));
		$table->row(array($this->_x('Summary', 'install-table'), $this->wire('sanitizer')->entities($data['summary'])));
		$table->row(array($this->_x('Release State', 'install-table'), $this->wire('sanitizer')->entities($data['release_state']['title'])));
		$table->row(array($this->_x('Compatibility', 'install-table'), $this->wire('sanitizer')->entities($compat)));
		
		// $this->message("<pre>" . print_r($data, true) . "</pre>", Notice::allowMarkup); 
		$installable = true; 
		if(!empty($data['requires_versions'])) {
			$requiresVersions = array();
			foreach($data['requires_versions'] as $name => $requires) {
				list($op, $ver) = $requires;
				$label = $ver ? $this->sanitizer->entities("$name $op $ver") : $this->sanitizer->entities($name);
				if($this->modules->isInstalled("$name$op$ver") || in_array($name, $data['installs'])) {
					// installed
					$requiresVersions[] = "$label <i class='fa fa-fw fa-thumbs-up'></i>";
				} else if($this->modules->isInstalled($name)) {
					// installed, but version isn't adequate
					$installable = false;
					$info = $this->modules->getModuleInfo($name);
					$requiresVersions[] = $this->sanitizer->entities($name) . " " . $this->modules->formatVersion($info['version']) . " " . 
						"<span class='ui-state-error-text'>" . $this->sanitizer->entities("$op $ver") . " " . 
						"<i class='fa fa-fw fa-thumbs-down'></i></span>";
				} else {
					// not installed at all
					$requiresVersions[] = "<span class='ui-state-error-text'>$label <i class='fa fa-fw fa-thumbs-down'></i></span>";
					$installable = false; 
				}
			}
			$table->row(array($this->_("Requires"), implode('<br />', $requiresVersions))); 
			if(!$installable) $this->error("Module is not installable because not all required dependencies are currently met."); 
		}
		if(!empty($data['installs'])) {
			$installs = $this->sanitizer->entities(implode("\n", $data['installs'])); 
			$table->row(array($this->_("Installs"), nl2br($installs))); 
		}

		$links = array();

		$moduleName = $this->wire('sanitizer')->entities1($data['name']);
		
		if($data['module_home']) {
			$moduleURL = $this->wire('sanitizer')->entities($data['forum_url']);
			$links[] = "<a target='_blank' href='$moduleURL'>" . $this->_('More Information') . "</a>";
		}

		if($data['project_url']) {
			$projectURL = $this->wire('sanitizer')->entities($data['project_url']);
			$links[] = "<a target='_blank' href='$projectURL'>" . $this->_('Project Page') . "</a>";
		}

		if($data['forum_url']) {
			$forumURL = $this->wire('sanitizer')->entities($data['forum_url']);
			$links[] = "<a target='_blank' href='$forumURL'>" . $this->_('Support Page') . "</a>";
		}

		if(count($links)) $table->row(array($this->_x('Links', 'install-table'), implode('  /  ', $links)));

		if($data['download_url']) {
			$downloadURL = $this->wire('sanitizer')->entities($data['download_url']);
			$table->row(array($this->_x('ZIP file', 'install-table'), $downloadURL));
			$warnings[] = $this->_('Ensure that you trust the source of the ZIP file above before continuing!');
		} else {
			$warnings[] = $this->_('This module has no download URL specified and must be installed manually.');
		}

		foreach($warnings as $warning) {
			$table->row(array($this->_x('Please Note', 'install-table'), "<strong class='ui-state-error-text'> $warning</strong>"));
		}

		$markup->value = $table->render();

		if($installable && $data['download_url']) {
			$btn = $this->wire('modules')->get('InputfieldSubmit');
			$btn->attr('id+name', 'godownload');
			$btn->value = $this->_("Download and install");
			$btn->icon = 'cloud-download';
			$btn->value .= " ($data[module_version])";
			$form->add($btn);
			$this->session->ProcessModuleDownloadURL = $data['download_url'];
			$this->session->ProcessModuleClassName = $data['class_name'];
		} else {
			$this->session->remove('ProcessModuleDownloadURL');
			$this->session->remove('ProcessModuleClassName');
		}

		$btn = $this->wire('modules')->get('InputfieldButton');
		$btn->attr('name', 'cancel');
		$btn->href ="./edit?name=$data[class_name]";
		$btn->value = $this->_("Cancel"); 
		$btn->icon = 'times-circle';
		$btn->class .= ' ui-priority-secondary';
		$form->add($btn);

		$form->description = $this->wire('sanitizer')->entities($data['title']); 
		return $form;
	}

	/**
	 * Format a module version number from 999 to 9.9.9
	 *
	 * @param string $version
	 * @return string
	 *
	 */
	protected function formatVersion($version) {
		return $this->wire('modules')->formatVersion($version); 
	}

}

Created with massive theft of code from ProcessModule.module;)

I'm going to toy around with this in our local environment and see if I can stitch together a nice workflow with the local git repo and a post-receive hook (once I find the time).

3 people like this

Share this post


Link to post
Share on other sites

Ask @ryan about the apikey. Maybe its just an option to limit requests in the future if needed. Currently only pw300 and pw280 is valid. I didn't check if there is a different return.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By cosmicsafari
      Hi All,
      I am working on a module at the moment which in theory will create a few simple fields, templates and pages which will all be linked together.
      All is going well so far, I have it generating said fields, templates and pages, however I would like to also set the pages sort order and icon programmatically at this stage also.
      I have yet to see any documentation or any other threads where this has been brought up, is it even possible programmatically without interacting with the database directly?
      This is the snippet which is generating my pages on the fly at the moment.
      foreach($arrayOfPages as $name => $page) { $p = new Page(); $p->template = 'page'; $p->name = $page['URL']; $p->title = $name; $p->parent = wire('pages')->get('name='.$page['parent']); //is it possible to set the icon and sort order at this point, before saving? $p->save(); }  
    • By Robin S
      I have had this module sitting in a 95% complete state for a while now and have finally made the push to get it out there. Thanks to @teppo for his Hanna Code Helper module which I referred to and borrowed from during development.
      http://modules.processwire.com/modules/hanna-code-dialog/
      https://github.com/Toutouwai/HannaCodeDialog
      HannaCodeDialog
      A module for ProcessWire CMS/CMF. Provides a number of enhancements for working with Hanna Code tags in CKEditor. The main enhancement is that Hanna tags in a CKEditor field may be double-clicked to edit their attributes using core ProcessWire inputfields in a modal dialog.
      Requires the Hanna Code module.
      Installation
      Install the HannaCodeDialog module using any of the normal methods.
      For any CKEditor field where you want the "Insert Hanna tag" dropdown menu to appear in the CKEditor toolbar, visit the field settings and add "HannaDropdown" to the "CKEditor Toolbar" settings field.
      Module configuration
      Visit the module configuration screen to set any of the following:
      Exclude prefix: Hanna tags named with this prefix will not appear in the CKEditor toolbar dropdown menu for Hanna tag insertion. Exclude Hanna tags: Hanna tags selected here will not appear in the CKEditor toolbar dropdown menu for Hanna tag insertion. Background colour of tag widgets: you can customise the background colour used for Hanna tags in CKEditor if you like. Dialog width: in pixels Dialog height: in pixels Features
      Insert tag from toolbar dropdown menu
      Place the cursor in the CKEditor window where you want to insert your Hanna tag, then select the tag from the "Insert Hanna tag" dropdown.

      Advanced: if you want to control which tags appear in the dropdown on particular pages or templates you can hook HannaCodeDialog::getDropdownTags. See the forum support thread for examples .
      Edit tag attributes in modal dialog
      Insert a tag using the dropdown or double-click an existing tag in the CKEditor window to edit the tag attributes in a modal dialog.

      Tags are widgets
      Hanna tags that have been inserted in a CKEditor window are "widgets" - they have a background colour for easy identification, are protected from accidental editing, and can be moved within the text by drag-and-drop.

      Options for tag attributes may be defined
      You can define options for a tag attribute so that editors must choose an option rather than type text. This is useful for when only certain strings are valid for an attribute and also has the benefit of avoiding typos.
      Add a new attribute for the Hanna tag, named the same as the existing attribute you want to add options for, followed by "__options". The options themselves are defined as a string, using a pipe character as a delimiter between options. Example for an existing attribute named "vegetables":
      vegetables__options=Spinach|Pumpkin|Celery|Tomato|Brussels Sprout|Potato You can define a default for an attribute as normal. Use a pipe delimiter if defining multiple options as the default, for example:
      vegetables=Tomato|Potato Dynamic options
      Besides defining static options as above, you can use one Hanna tag to dynamically generate options for another. For instance, you could create a Hanna tag that generates options based on images that have been uploaded to the page, or the titles of children of the page.
      Your Hanna tag that generates the options should echo a string of options delimited by pipe characters (i.e. the same format as a static options string).
      You will probably want to name the Hanna tag that generates the options so that it starts with an underscore (or whatever prefix you have configured as the "exclude" prefix in the module config), to avoid it appearing as an insertable tag in the HannaCodeDialog dropdown menu.
      Example for an existing attribute named "image":
      image__options=[[_images_on_page]] And the code for the _images_on_page tag:
      <?php $image_names = array(); $image_fields = $page->fields->find('type=FieldtypeImage')->explode('name'); foreach($image_fields as $image_field) { $image_names = array_unique( array_merge($image_names, $page->$image_field->explode('name') ) ); } echo implode('|', $image_names); Advanced: define or manipulate options in a hook
      You can hook HannaCodeDialog::prepareOptions to define or manipulate options for a Hanna tag attribute. Your Hanna tag must include a someattribute__options attribute in order for the hook to fire. The prepareOptions method receives the following arguments that can be used in your hook:
      options_string Any existing string of options you have set for the attribute attribute_name The name of the attribute the options are for tag_name The name of the Hanna tag page The page being edited If you hook after HannaCodeDialog::prepareOptions then your hook should set $event->return to an array of option values, or an associative array in the form of $value => $label.
      Choice of inputfield for attribute
      You can choose the inputfield that is used for an attribute in the dialog.
      For text attributes the supported inputfields are text (this is the default inputfield for text attributes so it isn't necessary to specify it if you want it) and textarea. Note: any manual line breaks inside a textarea are removed because these will break the CKEditor tag widget.
      Inputfields that support the selection of a single option are select (this is the default inputfield for attributes with options so it isn't necessary to specify it if you want it) and radios.
      Inputfields that support the selection of multiple options are selectmultiple, asmselect and checkboxes.
      You can also specify a checkbox inputfield - this is not for attributes with defined options but will limit an attribute to an integer value of 1 or 0.
      The names of the inputfield types are case-insensitive.
      Example for an existing attribute named "vegetables":
      vegetables__type=asmselect Descriptions and notes for inputfields
      You can add a description or notes to an attribute and these will be displayed in the dialog.
      Example for an existing attribute named "vegetables":
      vegetables__description=Please select vegetables for your soup. vegetables__notes=Pumpkin and celery is a delicious combination. Notes
      When creating or editing a Hanna tag you can view a basic cheatsheet outlining the HannaCodeDialog features relating to attributes below the "Attributes" config inputfield.
      Troubleshooting
      HannaCodeDialog includes and automatically loads the third-party CKEditor plugins Line Utilities and Widget. If you have added these plugins to your CKEditor field already for some purpose and experience problems with HannaCodeDialog try deactivating those plugins from the CKEditor field settings.
    • By joshuag
      Introducing our newest [commercial] module:
      Recurme
      Processwire Recurring Dates Field & Custom Calendar Module.
      http://www.99lime.com/modules/recurme/
      One Field to Recur them ALL…
      A Recurring Dates InputField for your Processwire templates. The InputField you’ve been waiting for.
      Complex RRule date repeating in a simple and fast user interface.
      Use the super simple, & powerful API to output them into your templates.
      example:
      <? // easy to get recurring events $events = $recurme->find(); // events for this day $events = $recurme->day(); // events for this week $events = $recurme->week(); // events for this month $events = $recurme->month(); ?> <? // Loop through your events foreach($events as $event){ echo $event->title; echo $event->start_date; echo $event->rrule; echo $event->original->url; ... } ?> Unlimited Custom Calendars.
      Imagine you could create any calendar you wanted on your website. Use recurring events with the Recurme field, or use your own Processwire pages and date fields to render calendars… it’s up to you. Fully customizable. Make as many calendars as you like. Get events from anywhere. Recurme does all the hard date work for you.
      Unlimited Custom Admin Calendars too.
      Hope you like it  ,
       Joshua & Eduardo from 99Lime.
       




    • By valan
      At our site we use both email and phone authorizations at frontend. To make life easier, I've developed HelperPhone pack that handles phone numbers. This pack includes following modules for ProcessWire CMS/CMF:
      FieldtypePhoneNumber: module that stores phone numbers InputfieldPhoneNumber: module that renders inputfield for phone numbers HelperPhone: module that loads PhoneNumber and PhoneNumberConst classes, and 'libphonenumber' namespace All these modules require included PW WireData-derived class PhoneNumber and PhoneNumberConst.
      PhoneNumber class is a thin wrapper over giggsey/libphonenumber-for-php, itself is port of Google's libphonenumber. PhoneNumberConst class stores constants, used by PhoneNumber class Usage: PhoneNumber class
      $phone = '8 (916) 318-07-29 ext 1234'; // input string could be in any phone-recognizable format $phoneNumber = new PhoneNumber($phone, 'RU'); // or wire('modules')->get('HelperPhone')->makePhoneNumber($phone, 'RU'); echo ($phoneNumber->isValidNumber() ? 'Yes':'No'); // Yes echo ($phoneNumber->isValidNumberForRegion($regionCode) ? 'Yes':'No'); // Yes echo $phoneNumber->getNumberTypeTitle(); // Mobile echo $phoneNumber->getCountryCode(); // 7 echo $phoneNumber->getRegionCode(); // RU echo $phoneNumber->getNationalNumber(); // 9163180729 echo $phoneNumber->getExtension(); // 1234 echo $phoneNumber->formatForCallingFrom('US') // 011 7 916 318-07-28 echo $phoneNumber->formatForCallingFrom('GE') // 00 7 916 318-07-28
      For more methods and properties please refer to PhoneNumber and PhoneNumberConst source files. Need more? Check giggsey/libphonenumber-for-php and use it by accessing $phoneNumber->phoneNumber property - it is instance of \libphonenumber\PhoneNumber or null (if empty).
      Usage: field
      Note: on field creation, make sure that you've configured field settings
      Default region: assumed region if input phone number string is not in international format (starts with '+', etc)
      Enabled/disabled phone extentions: if disabled, phone extension will be removed on field save.
      Phone field settings in example below: default region code 'RU', phone extensions are enabled
      echo $page->phone; // +79163180729 // Note1: $page->phone stores instance of PhoneNumber and renders to string in E164 format. // Note2: E164 format does not include extension. echo $page->getFormatted('phone'); // +7 916 318-07-29 ext. 1234 echo $page->getUnformatted('phone'); // +79163180729 echo $page->phone->format(PhoneNumberConst::RFC3966); // tel:+7-916-318-07-29;ext=1234 echo $page->phone->getNationalNumber(); // 9163180729 Usage: PW selectors
      FieldtypePhoneNumber is instance of FieldtypeText. It stores phone numbers and extensions as string in E164 format with #extention (if provided by user and enabled in settings) E.g. in db it looks like this: '+79163180729#1234'. This makes it easy to query fields as any text field.
      echo $pages->find([     'template' => 'my_temlate',     'phone^=' => '+79163180729', ]); // will echo page ids where phone starts with '+79163180729' Finally
      I've decided to put it here first and later to Modules directory (based on your feedbacks).
      GitHub: https://github.com/valieand/HelperPhone
      Enjoy
    • By Salemoche
      Hello

      I've just started my first processwire project and have set the back end to my liking. Upon starting the front end of my site I encountered a very strange problem: The CSS file is not updating.
      I started off and soon the problem occured. I then simply copied the contents of main.css to a new main2.css file, changed the code in the template file, and it worked again. Thinking it was a one time thing I continued, but it didn't take long for the problem to happen again.
      Locally the files are changed and the html code of my project is updating normally, but when I inspect the page, the changes in the CSS file are nowhere to be seen.

      I'm using MAMP to create the local server and Koala to compile my SASS Code.  I'm new to processwire and am still pretty early in my web developer career, nontheless I'm very confused about what's happening, since the problem is only partially occuring in the CSS file and not in the HTML (or php) file.
      Does anyone have an idea as to what the problem could be?
      Thanks in advance