
abdus
Members-
Posts
743 -
Joined
-
Last visited
-
Days Won
42
Everything posted by abdus
-
Multisites with same templates and different databases
abdus replied to shivrajsa's topic in General Support
I'm using PW from dev branch with Functions API enabled. In your config.php add $config->useFunctionsAPI = true https://processwire.com/blog/posts/processwire-3.0.39-core-updates/ Were you able to override assets directory altogether? -
For reference here's a simple mutation field implementation <?php wire()->addHookAfter('ProcessGraphQL::getMutation', function ($event) { $query = $event->return; $query->addField('log', [ // define return object under type 'type' => new ObjectType([ 'name' => 'Log', 'fields' => [ 'result' => [ 'type' => new StringType() ] ] ]), // available arguments for the query 'args' => [ 'text' => new StringType() ], // what to do with the request 'resolve' => function ($value, $args) { // process given input // return object outline should be same as 'type' return [ 'result' => 'done. ' . $args['text'] ]; } ]); }); When you refresh GraphiQL console, you get your new field!
-
Thanks for the guidance @Nurguly Ashyrov. The problem was that I wasn't including calling the module (and therefore not autoloading GraphQL classes) before I included mine. That was why it wasn't resolving. <?php // CORRECT $processGraphQL = modules()->get('ProcessGraphQL'); require_once 'api/SubscriptionField.php'; require_once 'api/SubscriptionType.php'; // INCORRECT require_once 'api/SubscriptionField.php'; require_once 'api/SubscriptionType.php'; $processGraphQL = modules()->get('ProcessGraphQL');
-
@Nurguly Ashyrov I am trying to build a mutation field for mailing list subscription that takes in email address and returns status code and error messages, if any. <?php namespace ProcessWire; // /site/templates/graphql.php use ProcessWire\Api\SubscriptionField; require_once '../modules/ProcessGraphQL/vendor/autoload.php'; $processGraphQL = modules()->get('ProcessGraphQL'); wire()->addHookAfter('ProcessGraphQL::getMutation', function ($event) { $query = $event->return; $query->addField(new SubscriptionField()); }); echo $processGraphQL->executeGraphQL(); Here's my SubscriptionField definition and my SubscriptionType class When I open the GraphiQL console, I get this error I am not sure why PHP can't find the class, any ideas? When I manually require field class (require_once 'api/SubscriptionField.php';), it resolves the class, but then cannot resolve others (error: Class 'Youshido\GraphQL\Field\AbstractField' not found)
-
Multisites with same templates and different databases
abdus replied to shivrajsa's topic in General Support
@gebeer, unfortunately PW ignores it. <?php $config->paths->assets = config()->paths->root . 'test/'; $config->urls->assets = config()->urls->root . 'test/'; // doesn't work :( -
When uploads get stuck on 100% and manual addition doesn't work
abdus replied to hellomoto's topic in General Support
You can use API to import files into your Pagefile fields. Here's the relevant bit from docs <?php // Adding new file(s) $page->files->add('/path/to/file.pdf'); $page->files->add('http://domain.com/photo.png'); $page->save('files'); I had a similar problem as yours where images uploads would get stuck. After I upgraded from v2.7 to v3.0, it went away. Also check your max POST request size limits on for PHP and your server. Inside php.ini you should see max_post_size setting, try increasing it. Check your permissions to /site/assets/ directory. Here are the recommended settings # Change the permission of ALL directories (recursively) # Replace site/assets with the name of the starting directory you want to change, and replace 755 with the permission you want to use. find site/assets -type d -exec chmod 755 {} \; # Change the permission of ALL files (recursively) # Replace site/assets/ with the name of the directory where files are located, and replace 644 with the permission you want to use. find site/assets/ -type f -exec chmod 644 {} \; -
Multisites with same templates and different databases
abdus replied to shivrajsa's topic in General Support
You might need to override paths for other site specific directories, such as cache, logs, sessions to get a better separation. If it were possible override assets directory altogether, that would be much better, but for now, this should suffice. If anyone knows how to override /site/assets/ path, I'd love to be enlightened. -
Or maybe use $moduleConfig instead of causing fragmentation. <?php // Schema.php public function build(SchemaConfig $config) { // $moduleConfig is an instance of ProcessGraphQL module $moduleConfig = Utils::moduleconfig(); $customQueries = $moduleConfig->___getQueries(); $customMutations = $moduleConfig->___getMutations(); $query = $config->getQuery(); $mutation = $config->getMutation(); $query->addFields($customQueries); $mutation->addFields($customQueries); // then populate your own fields etc. }
-
Thanks a lot for the changes, it works without a problem now Also, is it possible for you to add some hookable functions to the module so that we can add custom queries and mutations? Inside Schema::build(), query and mutation fields are defined, maybe split build() method into ___getMutations and ___getQueries, then we can modify $event->returns inside hooks to add our own fields? Something like this maybe: <?php // maybe build parameters in // /ProcessGraphQL/ProcessGraphQL.module public function ___getQueries() { // build an assc. array of FieldInterface objects return [...]; } public function ___getMutations() { // build an assc. array of FieldInterface objects return [...]; } public function executeGraphQL() { // instantiating Processor and setting the schema $schema = new Schema($this->___getQueries(), $this->___getMutations()); $processor = new Processor($schema); // ... } then inside Schema.php you would just use the provided fields. <?php class Schema extends AbstractSchema { private $queries = []; private $mutations = []; public function __construct($queries, $mutations) { // populate fields, perform checks etc } public function build(SchemaConfig $config) { $moduleConfig = Utils::moduleconfig(); $query = $config->getQuery(); $mutation = $config->getMutation(); // add other query fields $query->addFields($this->queries); $mutation->addFields($this->mutations); } } It's a proof of concept, needs better separation of concerns etc, but it should work, why wouldn't it.
-
Have you imported templates as well? Importing fields without referenced templates throws errors.
-
Changelog support in ProcessWireUpgrade module
abdus replied to szabesz's topic in Wishlist & Roadmap
Can't we use upgrade() function inside modules to achieve this? It's not as eloquent as having the changelog available before downloading new version, but developers can use it to display certain info, and request confirmation during/abort if possible. Something like this: <?php namespace ProcessWire; class MyModule extends Module { // ... // (module implementation) // ... public function upgrade($from, $to) { // TODO: remove after v2.0 // upgrading to v2.0, show warning about breaking changes if(strpos($from, '1.') === 0 && strpos($to, '2.') === 0) { $this->warning("New version includes <strong>breaking</strong> changes. See module info page for details.", Notice::allowMarkup); // create some info page, display compiled output of README.md // not sure how to display info on Process pages if (!$accepted) { throw new WireException('Cannot install without confirmation'); } } return $to; } } -
Multisites with same templates and different databases
abdus replied to shivrajsa's topic in General Support
By overriding $config->paths and $config->urls, I got it to work. Both sites use different directories for uploads unaware of each other. I couldn't override $config->site->assets, which would have been a much better option, anyone know how? <?php $config->dbHost = 'localhost'; $config->dbPort = '3306'; $config->httpHosts = array('pw.dev', 'pw2.dev'); if($_SERVER['HTTP_HOST'] == 'pw.dev') { $config->dbName = 'pw'; $config->dbUser = 'pw'; $config->dbPass = 'password'; $config->paths->files = $config->paths->site . '/assets/files-first/'; $config->urls->files = $config->urls->site . '/assets/files-first/'; } else /*if ($_SERVER['HTTP_HOST'] == 'pw2.dev')*/ { // remember to default to some site if HTTP_HOST is not set! $config->dbName = 'pw_dev'; $config->dbUser = 'pw_dev'; $config->dbPass = 'password'; $config->paths->files = $config->paths->site . '/assets/files-second/'; $config->urls->files = $config->urls->site . '/assets/files-second/'; } Checking path is quite good, I'll probably implement some setup like this to set up a staging environment. Right now I'm just using reverse SSH tunnel to redirect localhost to web. One thing however, since both sites use the same templates, paths wouldn't be different, but you can create a symlink to solve that. -
Warning about Server Locale after update from 3.0.52 > 3.0.53 - Help!
abdus replied to EyeDentify's topic in General Support
Is this the whole output? It's been a long time since I last used CPanel, but can you pick a locale from the list and install? Have you tried it? If setlocale() can't find the provided locale, it defaults to 'C', (in your case only zu_ZA.utf8 is installed). setlocale() sets locale for the current execution context (Processwire instance) and is inherited in child scopes (unless overriden). It gets locale definitions from hosting server, but to enable a locale you may need to set something on CPanel.- 40 replies
-
- serverlocale
- 3.0.52
-
(and 1 more)
Tagged with:
-
<?php foreach($page->galerie as $image) { // where's $thumbnail defined? it should have been $image->description, I suppose? echo "<a href='{$image->url}' data-fancybox="images-single" title='{$thumbnail->description}'></a>"; } ?> You might need to change $thumbnail to $image, are you getting any error? Do you have TracyDebugger installed?
-
Multisites with same templates and different databases
abdus replied to shivrajsa's topic in General Support
You're probably not allowed to make changes in server, or install new packages if you're on a shared hosting (judging by the use of CPanel). But I am guessing it's possible, because reading the guide on the link you posted, there's this screenshot. This probably allows pointing to same directory However, you will probably need to upgrade your hosting account for multiple domains. Also if you use this setup, databases will be unique but since both setups point to same /site directory, assets folders will eventually clash since both sites are unaware of the other's page ids. To solve this you may need to change site path as well. I'll look into how when I am back on PC. Edit: solved it below -
Warning about Server Locale after update from 3.0.52 > 3.0.53 - Help!
abdus replied to EyeDentify's topic in General Support
You're missing a semicolon after echo statement on line 2. You can provide an array of locales as well. I would check what locales installed on the server. This http://www.binarytides.com/php-get-list-of-locales-installed-on-system/ script may help you debug it if you dont have ssh access to the server. If you do, locales -a command lists all installed locales.- 40 replies
-
- serverlocale
- 3.0.52
-
(and 1 more)
Tagged with:
-
Multisites with same templates and different databases
abdus replied to shivrajsa's topic in General Support
I tried it, it works just fine. Here's how you do it Create a new database for the other site(s). Add new database user and set correct permissions & privileges. I duplicated mine by dumping into .sql file, changing its name then reimporting in Adminer panel Go to config.php, update $config->httpHosts to include other domains, then add new database info like so: $config->dbHost = 'localhost'; $config->dbPort = '3306'; $config->httpHosts = array('pw.dev', 'pw2.dev'); if($_SERVER['HTTP_HOST'] == 'pw.dev') { $config->dbName = 'pw'; $config->dbUser = 'pw'; $config->dbPass = 'password'; } else if ($_SERVER['HTTP_HOST'] == 'pw2.dev') { $config->dbName = 'pw_dev'; $config->dbUser = 'pw_dev'; $config->dbPass = 'password'; } Update your HTTP server configuration. I use Caddy Server, which makes these changes trivial. # old pw.dev:80 { root /www/pw/ # other configs } # add new host pw.dev:80, pw2.dev:80 { root /www/pw/ # other configs } # both hosts share the same root! Reload HTTP server (Apache, nginx, Caddy etc) and enjoy! Here it is in action: 2017-04-07_11-56-11.mp4 (1MB video, 00:24 sec) -
Where have page tree bookmarks and page edit bookmarks gone?
abdus replied to Robin S's topic in General Support
It turns out it's hidden under ProcessPageEdit module configuration. Then you can follow the navigation to add bookmarks -
Better mobile reading experience for code snippets in forum
abdus replied to abdus's topic in Wishlist & Roadmap
Another improvement would be supporting some subset of markdown. It's much easier to write code snippets in Github Flavored and Markdown Extra. They support fenced code with backticks, which allows you specify the language for syntax highlighting with backticks as well (```php for example). Having to fiddle with font settings to indicate inline code snippets is frustrating when you're able to just surround it with backticks in Markdown `like this`. A disadvantage would be the inability to use align/colors/font/size options, but they're distracting anyway and lack of only brings more consistency to the content structure. https://github.com/timsayshey/Ghost-Markdown-Editor is a really good editor concept, you can put placeholders, then add images later -
Multisites with same templates and different databases
abdus replied to shivrajsa's topic in General Support
You should be able to point to different databases in your config.php depending on hostname. Something like this _should_ work, but I haven't tried it: <?php // config.php if($_SERVER['HTTP_HOST'] == 'firstsite.com') { $config->dbHost = 'localhost'; $config->dbName = 'db_for_first_site'; $config->dbUser = 'user'; $config->dbPass = 'password'; } else if ($_SERVER['HTTP_HOST'] == 'secondsite.com') { $config->dbHost = 'localhost'; $config->dbName = 'db_for_second_site'; $config->dbUser = 'anotheruser'; $config->dbPass = 'password'; } -
Thanks for the clarification. The problem is that if I dont specify any selector, I get empty array, also an error But if I specify a selector, it all works fine I'm not sure if this is the expected behavior.
-
When I go to GraphiQl interface, selector argument for template fields does not appear to be optional as it's in the screencast. However, if I provide a selector, it works as expected. Do I need to set up something on backend? How it looks on my GraphiQL: How it is in the screencast
-
Code snippets are very hard to read on small screens due to lack of white-space: pre CSS property on <pre> tags. This causes very weird text wrapping. Adding this allows code to scroll sideways, which also preserves the whitespace properly. Here's the problem and proposed change in action Readable on large screens, overflow works ✓ Unreadable on small screens, text should not wrap ✘ Proposal: add white-space: pre on <pre> elements. See it in action 2017-04-05_20-18-03.mp4 (770KB) or GIPHY link
-
When using Markdown, you can put two spaces before a line break to insert a soft break. first line␣␣ (two spaces before line break) second line // this would render as <p>first line<br/>second line</p>