-
Posts
2,776 -
Joined
-
Last visited
-
Days Won
40
Everything posted by Macrura
-
modifying $config property (e.g. siteSettings) from ready.php
Macrura replied to Macrura's topic in General Support
ok great, yeah i just changed to that and all appears to work fine... Will update the code above with the 'final' answer... -
modifying $config property (e.g. siteSettings) from ready.php
Macrura replied to Macrura's topic in General Support
I read through most of the replies here, and tried to analyze what the best way to improve upon the original post/request. So far this is the version working with devns branch; it is similar to the original method posted, but uses suggestions from Soma, tpr and LostKobrakai... $this->wire("config")->site = new WireData(); $st = $pages->get('/settings/')->settings_table; foreach($st as $row) { if(!$row->value) continue; if($row->disable == 1) continue; $thisKey = $row->setting; $this->wire("config")->site->$thisKey = $row->value; } This allows the site settings from the database to be accessible everywhere needed, and not have to init the array in config.php. The syntax is slightly cleaner/easier than using the array style. $this->wire('config')->site->pub_search_pattern; or in a template: $config->site->pub_search_pattern; -
yes - it autosaves it in local storage, which is why the module init would need to ID each field with it's page id and instance id... so by default the autosave is off (and probably not necessary)...
-
seems the init state does not show the lines/words counter - this is a documented issue with the plugin, see https://simplemde.com/ you can force it to update on load by enabling autosave; (adding these to the init call) autosave: { enabled: true, uniqueId: thisID, delay: 1000, }, spellChecker: false the plan is to make each instance individually configurable, but for now this is a very bare-bones implementation. i'm going to add those options to the js init, but maybe leave them commented out, and let users uncomment to disable spellcheck, and enable autosave; BTW - the autosave is interesting and works, not sure how useful it is or even if it makes sense in the context of a CMS. if it were to be enabled, additional configuration would be required to change the way it works so as to have a unique id for the page and the field though.
-
an unwanted button link shown on my custom Process module
Macrura replied to adrianmak's topic in General Support
head_button_clone (i think) -
Basic implementation of the Simple MDE as an Inputfield. https://simplemde.com/ Module developed in reply to request from @OrganizedFellow (https://processwire.com/talk/topic/13474-found-a-handy-js-based-markdown-editor/) Modules Directory: http://modules.processwire.com/modules/inputfield-simple-mde/ Github: https://github.com/outflux3/InputfieldSimpleMDE Editor example: Preview mode: Frontend output (using Markdown/Parsedown textformatter and Image Tags) Limitations etc: This has been tested with multiple instances on 1 page and seems to work fine. Toolbar is not configurable, but you can edit the JS file; In the spirit of keeping this simple, there are no module settings. If you want the spellchecker, you can enable it in the JS file. If is seems that there is a need for configurable instances, it could be added, but so far this works fine and can't see any reason to complicate it further.
- 37 replies
-
- 20
-
-
awesome thanks for putting that together, i think this should go on recipes site, in fact it would be cool if there were a module that could let users setup toolbars in a graphical ui, eventually... for now maybe there could be some pre-defined sets that users could copy/paste, like "kitchen sink" (attr Wordpress)...
-
just threw together a quick module for this and works well so far.. needs some testing but might be able to get this on github in a few days; in the meantime, here are some screens: Preview Mode: OK, here it is.. https://processwire.com/talk/topic/13486-inputfieldsimplemde/#entry121650
- 1 reply
-
- 15
-
-
actually this is in the core, all you need to do is add these to your toolbar (you don't need to add any plugins): so where your first line would look like this out of the box: Format, Bold, Italic, -, RemoveFormat you can change it to be like this: Format, Bold, Italic, Underline, -, RemoveFormat, -, TextColor, BGColor
-
oops sorry meant this https://search.google.com/structured-data/testing-tool to see the json i usually dump it to tracy debugger
- 34 replies
-
- 2
-
-
- structured
- data
-
(and 2 more)
Tagged with:
-
I always use the google testing tool anyway to see how the data is being read, so i never even look at the source code (lol)
- 34 replies
-
- structured
- data
-
(and 2 more)
Tagged with:
-
sure, here are some examples, i have these in a file called schema_helpers.php, which is in my shared functions folder: 1.) function siteSchema() { $page = wire('page'); $schema = array( "@context" => "http://schema.org", "@type" => "Website", "url" => wire('pages')->get(1)->httpUrl, "name" => $page->title, "description" => '', "potentialAction" => array( "@type" => "SearchAction", "target" => wire('pages')->get(1000)->httpUrl . "?q={search_term}", "query-input" => "required name=search_term" ), "about" => array( "@type" => "Thing", "name" => "A very interesting THING", "description" => "Website about a very interesting THING" ) ); if($page->summary) { $schema['description'] = $page->summary; } else { unset($schema['description']); } return '<script type="application/ld+json">' . json_encode($schema) . '</script>'; } 2.) News function jsonldNews($item, $settings) { $image = $item->image ?: getFallbackImage($item); if(!$image) return; $out = ''; $jsonld = array(); $jsonld["@context"] = "http://schema.org/"; $jsonld["@type"] = "NewsArticle"; $jsonld["name"] = $item->title; $jsonld["headline"] = $item->title; $jsonld["url"] = $item->httpUrl; $jsonld["mainEntityOfPage"] = array( '@type' => "WebPage", '@id' => $item->httpUrl ); $jsonld["description"] = $item->summary; $jsonld["datePublished"] = date(DATE_ISO8601, $item->published); $jsonld["dateModified"] = date(DATE_ISO8601, $item->modified); $jsonld["dateline"] = date(DATE_ISO8601, strtotime($item->news_date)); $jsonld["wordCount"] = str_word_count($item->body); $jsonld['author'] = $settings['author']; $jsonld['publisher'] = $settings['entity']; $jsonld['articleBody'] = $item->body; $jsonld['articleSection'] = $item->categories_select->first()->title; // Publisher $pubLogo = wire('pages')->get(3525)->image; if($pubLogo) { $pubLogo = $pubLogo->height(60); $jsonld['publisher'] = array( '@type' =>'Organization', 'name' => 'A Publisher', 'url' => 'https://publisher.org/', 'logo' => array ( '@type' => 'ImageObject', 'url' => $pubLogo->httpUrl, 'height' => $pubLogo->height, 'width' => $pubLogo->width ) ); } // News Items may have a featured image $image = $image->width(696); $jsonld['image'] = array( "@type" => "ImageObject", 'url' => $image->httpUrl, 'height'=> $image->height, 'width' => $image->width ); $out .= '<script type="application/ld+json">' . json_encode($jsonld) . '</script>'; return $out; } 3.) Event function jsonldEvent($event) { if(!$event->event_location_select) return; if($event->template == 'event-child') { // inherit unset fields needed $event->event_link = $event->event_link ? : $event->parent->event_link; $event->body = $event->body ? : $event->parent->body; $event->event_location_select = $event->event_location_select ? : $event->parent->event_location_select; $event->price = $event->price ? : $event->parent->price; $event->currency_code = $event->currency_code ? : $event->parent->currency_code; $event->link = $event->link ? : $event->parent->link; } $out = ''; foreach($event->event_date_m as $ed) { $jsonld = array(); $date8601 = date(DATE_ISO8601, strtotime($ed)); $jsonld["@context"] = "http://schema.org/"; $jsonld["@type"] = "MusicEvent"; $jsonld["name"] = $event->title; $jsonld["url"] = $event->event_link; $jsonld["description"] = $event->body; $jsonld["startDate"] = $date8601; if($event->event_location_select) { $state = $event->event_location_select->state ? $event->event_location_select->state->title : $event->event_location_select->address_state; $jsonld["location"] = array( "@type" => "Place", "name" => $event->event_location_select->title, "url" => $event->event_location_select->link, "address" => array( "@type" => "PostalAddress", "streetAddress" => $event->event_location_select->address_street, "addressLocality" => $event->event_location_select->address_city, "addressRegion" => $state, "postalCode" => $event->event_location_select->address_zip, "addressCountry" => $event->event_location_select->country->title ) ); } if($event->price && $event->currency_code && $event->link) { $jsonld["offers"] = array( "@type" => "Offer", "description" => "Tickets", "price" => $event->price, "priceCurrency" => $event->currency_code, "url" => $event->link ); } $out .= '<script type="application/ld+json">' . json_encode($jsonld) . '</script>'; } return $out; } Also - I don't think you need to use JSON_PRETTY_PRINT
- 34 replies
-
- 6
-
-
-
- structured
- data
-
(and 2 more)
Tagged with:
-
I'm doing all my structured data with helper functions, and for most sites i will have around 5-6 schema.org types. I have found that this is a major benefit for SEO, and for search results accuracy in general. Not to mention that some other 'competing' CMSs provide some structured data plugins or out-of-the box generated markup, and while it is generated automatically and therefore not always totally accurate, it has been shown to give some of those sites an edge on search rankings, and placement in things like google events, or news.
- 34 replies
-
- 1
-
-
- structured
- data
-
(and 2 more)
Tagged with:
-
a quick way to do this would be to use RuntimeMarkup field: in that field code you would determine the outcome of the test (check to see if this page is in a page select from the other page) and the output a field with value 1 or 0; for example if your field was called inPageSelect, then you'd get the runtime markup to output a hidden field with a value of 1 or 0, and then in your dependency you'd put show if "inPageSelect=1"
-
running crazy fast here (in the heart of IBM-land)
-
just a quick reply with some comparisons here also since i have DT running on several sites now... - HTML table (a.k.a DOM) in this case the HTML is already on the page, but DataTables needs to read this HTML table and completely process it, remove it from the DOM, and render it. For any table with a lot of rows or columns, this is a bad option. - JSON Object Instead of using an HTML table, you can spit out the table info as JSON on the page somewhere in a var. Since this is the native language of DT, this is very, fast, for any table data where the total object is around 1MB or less. Still with 1MB you can have a significant amount of rows/columns/markup in your JSON. Also, if you use $cache,or ProCache, then the page load is very fast, and the DT rendering is almost instantaneous. - AJAX Ajax is almost the same as JSON object above but the JSON data lives on a separate URL, like on a service page. Still the JSON object is the full object, and even cached, this method is slower than inline JSON object because then the user is requesting 2 pages. This only makes sense when you have JSON that is probably more than 1MB and you don't want to have a large page load on the page that shows the table. So you have the page load fast, but the user has to wait a while for the server to respond to the ajax, and then for DT to process all of that JSON. Datatables only makes 1 call on the ajax to get the data, so this is why you have to weigh AJAX vs. JSON object and do testing; In all of my tests, JSON object was the fastest and i'm dealing with about 1/2MB size JSON object. - SSP This is completely different than the above, because in this case the server needs to deliver the records only as they are needed to be viewed by the user. Kongondo's example above would be a great way to get into this. It will probably be slower than JSON Object when dealing with small data sets, but for anything significant this is the best and only way to do it. I also wonder how much pages->findMany will make this work better; In the case of SSP, you are always needing to paginate from the server, i guess the findMany would allow you to make less pages->find and thus make the table appear more responsive
- 17 replies
-
- 3
-
-
- jquery
- datatables
-
(and 1 more)
Tagged with:
-
as a follow up to this, i have a module for image tags, using selectize.js; 1.) install the shared js lib: https://github.com/outflux3/JquerySelectize 2.) install the image tags module https://github.com/outflux3/SelectizeImageTags i have it working on several sites without issues, but this module should be considered Alpha. Documentation is also at an early stage. please report any issues or questions here. Once these are all stable and have had some testing/documentation, they will be added to the modules directory. (note these represent the start of a series of modules that utilize selectize.js, including an awesome page select Inputfield)
-
@Charles - i have it running on that same version with no errors; what version of PHP are you running with that?
-
@ottgal, you could try it out on a test install, and report back here (for example using MAMP etc.) In fact it is always a good idea to test modules on a test installation before installing them on a live production site. Most modules in the directory work fine on the latest version of PW. There are 1 or 2 modules that need some case fixing to work with all newer versions of PW, but the compiler is there to make usage of the 3.x branch as glitch-free as possible.
-
Module Module: RuntimeMarkup Fieldtype & Inputfield
Macrura replied to kongondo's topic in Modules/Plugins
cool - yeah the only slight snafu is that if you want syntax highlighting, you have to add an opening php tag, so if i'm editing, i add that and then i delete it before saving; not sure though if there is any way around that, but haven't looked into it yet... -
Thanks, what is strange is as i mentioned these appear to be completely random in terms of why they exhibit this error; it may be nothing directly due to TD; some of these that exhibit the error have much less data/info on the page than other siblings which don't crash; i've been trying to figure out if there is some deep error somewhere in the code that could be causing it, will keep tracking it down..
-
OK- sorry about this, i did as you recommended and was able to get rid of the error by disabling the ProcessWire Info panel; So yes, something about that panel and not sure if it related to the lines which are referenced in the error which all pertain to track changes.
-
Hi Adrian, i tried both master and dev, and also tried disabling all panels, but the error persists either way; These pages do have multiple tables, however the ones that exhibit the error are actually much less populated than some of the pages that have those tables populated. The tables themselves are only 3-5 columns and max 10 rows.
-
Hi Adrian, I'm trying to track down a mysterious issue that affects Tracy Debugger; i have a set of pages all using the same template, and there are a set of 5 of these pages that all exhibit the same problem, the tracy bar doesn't load and i get one of these errors: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 82 bytes) in /home/user/public_html/wire/core/Page.php on line 1611 Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 130968 bytes) in /home/user/public_html/wire/core/Wire.php on line 1048 For all of the other 176 siblings, everything works fine... This doesn't affect the live site at all, but there does seem to be something odd going on between tracy and these particular pages on the front end, as tracy loads fine on the PW page editor for these pages...
-
Module Module: RuntimeMarkup Fieldtype & Inputfield
Macrura replied to kongondo's topic in Modules/Plugins
I added this small tweak to the FieldType, which allows me to use the Ace extended for my code editing.. if(wire('modules')->get('InputfieldAceExtended')) { $f = $this->modules->get('InputfieldAceExtended'); $f->mode = "php"; $f->theme = "monokai"; } else { $f = $this->modules->get('InputfieldTextarea'); }