-
Posts
2,765 -
Joined
-
Last visited
-
Days Won
40
Everything posted by Macrura
-
@BernhardB - actually i think it would be easier to copy all of the necessary options right into the table select field selectable options; I'm doing that now on one site and it works, but you would need to update the selectable options manually... maybe there is a way to have a module use the api to update the selectable options, for example when a new page under a certain parent is added, this triggers an update of those selectable options...
-
wish i had a remote concept of what AngularJS is/does and how it could be used with PW...
-
pretty sure that this only works for children of the page (showing new pages that can be added)... but will need to test it to confirm... @Michael Murphy - this would basically be equivalent to my module in progress (currently an admin custom pages drop in), which would allow you to use regular page selects, but have the ability to access/edit them in a modal by clicking on the title.. you wouldn't be able to mix and match these with pagetables; i think of page table pages as pages that have to directly relate to to the page and can't be altered by any other page. https://processwire.com/talk/topic/7588-admin-custom-files/?p=81866 there are other ways you could achieve various functionality - for example write a module that clones the pages in a page select to new page table pages where you could then have contextual access to those new pages without the risk of affecting some other place that page is being used;
-
Add a new action button to page edit screen
Macrura replied to Ivan Gretsky's topic in Themes and Profiles
yes - this is a texbook page table scenario... -
Add a new action button to page edit screen
Macrura replied to Ivan Gretsky's topic in Themes and Profiles
@Ivan, Part of my stock toolkit when building sites is a "save action". It is a simple way to run some action when the user saves; they select the save action, and click save, and the action runs. It usually hooks into SaveReady. It could be anything from calculating/validating/correcting/filling in blank fields to things like deleting children, renaming assets (images, files) etc.. I usually use a special select field for this, but you could use a checkbox. If I needed to create the functionality you are describing right at this moment, i would make the save action a checkbox and then have next to it After save: Create new classified Item; your module code would then simply create a new page under the specified parent and redirect the user to that edit page... -
@BernhardB - the way that i would attempt to do it (and this is just thinking out loud..) would be to create a page select field on that template, which i would then hide with css, from where to get the page ids and names; then i would use jquery to grab all of the page names and ids (into a js array) and use that data to create a selector (would probably use chosen) which i would place into all of the fields in the first column; it would need to store the page id in the field value, but then when viewing it, the chosen select would show the label..
-
hey Martijn- that's another cool tip -thanks a lot!; in this case i'm loading the scripts in a module (sort of a site utility module that i use on all sites..) like this: $this->config->scripts->add($this->config->urls->JqueryMagnific . 'JqueryMagnific.js'); $this->config->styles->add($this->config->urls->JqueryMagnific . 'JqueryMagnific.css'); so seeing that the js is expecting their to be a modal script loaded, i think to make this more manageable i should just finish the support for page list selects and then make it a module...
-
ok thanks - got it now.. here's a drop in i'm working on: AsmSelectLinks - which adds links so you can edit your Asm and Page Autocomplete pages by clicking on them.. this is a rough first version, but i think it can get better. The only major issue is with the loading of magnific which would be required; i guess this will probably need to be a module, so that it can load the magnific and the 2 files.. javascript: $(function(){ $('div.InputfieldPageAutocomplete').each(function(){ $('ol li', this).each(function(){ var id = $(this).find('span.itemValue').text(); $(this).find('span.itemLabel').wrapInner(" <a class='edit-modal' href='"+config.urls.admin+"page/edit/?id="+id+"&modal=1' target='_blank'></a>"); }); }); $('div.InputfieldAsmSelect').each(function(){ $('select option', this).each(function(){ id = $(this).val(); rel = $(this).attr('rel'); $('li.asmListItem[rel='+rel+']').find('span.asmListItemLabel').wrapInner(" <a class='edit-modal' href='"+config.urls.admin+"page/edit/?id="+id+"&modal=1' target='_blank'></a>"); }); }); $('div.InputfieldPageListSelectMultiple').each(function(){ $('ol li', this).each(function(){ var id = $(this).find('span.itemValue').text(); $(this).find('span.itemLabel').wrapInner(" <a class='edit-modal' href='"+config.urls.admin+"page/edit/?id="+id+"&modal=1' target='_blank'></a>"); }); }); }); $(document).ready(function(){ $('a.edit-modal').magnificPopup({ type: 'iframe'}); }); css: .mfp-iframe-holder .mfp-content { max-width: 1200px!important; } a.edit-modal:hover { text-decoration: underline; } ... this feature has been a huge time saver because (especially during development) you often need to edit/access those pages that are being selected.. planning on also getting it to work with page list selects..
-
@Martijn - i'm having trouble understanding what that means... so how would i get ProcessPageEditTruncate.js to load on my PageEdit process - do i need to create a new process?
-
Module In Progress... working on an Inputfield which will allow the updating of the select description (for contextual description of the actual selected item) based on the selected option. This module is/was mostly written by netcarver, so i'm just getting the details together and some jquery for this to work... https://processwire.com/talk/topic/419-extending-inputfields/?p=76823 i'm thinking that the module title should probably be more specific?, like InputfieldSelectDataDescription... in case there were other 'extended' interpretations...? module so far: <?php class InputfieldSelectExtended extends InputfieldSelect { public static function getModuleInfo() { return array( 'title' => __('Select Extended', __FILE__), 'version' => 1, 'summary' => __('Selection with extended attributes. An enhancement to select', __FILE__), 'permanent' => false, ); } /** * inputfield is loaded */ public function init() { // append script needed for the inputfield $this->config->scripts->add($this->config->urls->InputfieldSelectExtended . 'InputfieldSelectExtended.js'); } /** * Adds an option with extended attributes that allow mutually exclusive groups. */ public function addOption($value, $label = null, array $attributes = null) { if ( is_null($value) || (is_string($value) && !strlen($value)) ) { return $this; } if (null === $attributes) { $attributes = array(); } $extra_atts = $this->extendAttributes($value, $label); $attributes = array_merge($attributes, $extra_atts); return parent::addOption($value, $label, $attributes); } /** * Hook this and return an array with whatever extended attributes you need. * */ public function ___extendAttributes($id, $value) { $atts = array(); $page = wire()->pages->get($id); $atts['data-description'] = $page->data_description; return $atts; } } the js, so far - works, but doesn't account for multiple selects yet. InputfieldSelectExtended/InputfieldSelectExtended.js $(document).ready(function() { var $default = $('.InputfieldSelectExtended').prev('p.description').html(); $('.InputfieldSelectExtended select').change(function(){ var $selected = $(this).find(':selected'); var $description = $('.InputfieldSelectExtended').prev('p.description'); if($selected.data('description') == null ) $($description).html($default); $($description).html($selected.data('description')); }).trigger('change'); }); once installed you would need to add this inputfield to the list; then select the inputfield on your page field your selectable pages would need a data_description field. here is the result, before option selected: after select: i guess once i get the module more advanced, there would be a way to get some of these things automatically setup.. also - for this to work, you need to set a description for the page select field, so there is something to replace...
-
@owzim - thanks for the tips; good to know and i'll add that to the KB... oddly i'm using that code now and it works perfectly... but i do wonder what would happen if there was a colon in the string..
-
another use i just found is for rapid prototyping of repeating content, prior to committing to real fields. for example i'm making a testimonials slider for a client, but they have been tentative about many things on their site, so i'm not setting up any fixed fields now until they commit to certain elements of the front end; example - author: William role: Client text: Integer eu libero sit amet nisl vestibulum semper. Fusce nec porttitor massa. In nec neque elit. Curabitur malesuada ligula vitae purus ornare onec etea magna diam varius. - author: James role: Hippie text: Posuere erat a ante venenatis dapibus posuere velit aliquet. Duis llis, est non coeammodo luctus, nisi erat porttitor ligula, egeteas laciniato odiomo sem.
-
@hafa - this would need to be inside a module - maybe take a look at the helloworld module, or check this out: https://processwire.com/talk/topic/1908-automatically-generating-new-page-names/?p=48421 as far as uniqueid - you would want to use that if you don't care about anything with security, just for random numbers; if you wanted something more cryptographically sound, maybe try flourish fCryptography - there is a flourish autoloader module for processwire. - - - http://php.net/manual/en/function.uniqid.php
-
@hafa - i would probably make a module that uses a different crypto library, maybe flourish although this looks like it might be in beta.. also found this.. http://www.gilfether.com/phpcrypt/ would be easy to make the module to generate the slug; i think examples were provided earlier in this thread
-
@Kemal, maybe roll your own sitemap? it's super easy and then you can control what it includes by altering the selectors.. http://processwire.com/talk/topic/3846-how-do-i-create-a-sitemapxml/
-
solved: i failed to put the full folder of the getid3, i had just copied only the main class file.. major facepalm @adrian - forgot to thank you for helping.. (was actually replying to your post when the solution dawned on me..) by the way, this is pretty awesome, now i can read id3 tags and create pages based on those tags; also prevent users from uploading mp3 files where the bitrate is too high (in order to keep the filesizes small we use 128 for streaming files)...
-
@bracketfire - this should work: $facility->region_page = '';
-
Hi - I was able to read id3 tags from audio files very easily using this library and the api, but now i'm stuck trying to get this to work inside a module; in my api test, i just did this: $templates = $config->paths->templates; require_once("{$templates}tools/getid3/getid3.php"); $getID3 = new getID3; $album = $pages->get(2130); foreach($album->children as $track) { $audio = $track->audio_file_p; // Analyze file and store returned data in $track->tags $track->tags = $getID3->analyze($audio->filename); echo $track->tags['tags']['id3v2']['title'][0]; echo $track->tags['tags']['id3v2']['artist'][0]; echo $track->tags['tags']['id3v2']['track_number'][0]; echo $track->tags['audio']['bitrate']; echo $track->tags['playtime_string']; } but now in trying to get this to work inside a module, i can't get the id3 to return the array, not sure what I'm doing wrong... this code is within a method that runs on a saveReady hook: <?php require_once(dirname(__FILE__) . '/getid3.php'); $getID3 = new getID3; $file = $page->audio_files->first(); $tags = $getID3->analyze($file->filename); $title = $tags['tags']['id3v2']['title'][0]; $this->message($title); I did a print_r into a spare field on the $page but it only returned the number 1.. i guess there is something that isn't quite right about the file path or the way the classes are working together? thanks!
-
Repeater field and visibility rule storage problem
Macrura replied to Juergen's topic in General Support
@Juergen - i don't think dependencies can work within repeaters; Have you checked the js console? maybe this helps? -
return field value inside repeater inside TableField
Macrura replied to sakkoulas's topic in General Support
Have you tried echoing the values through the code to make sure that your comparisons will work? <?php foreach ($page->pageTable as $pt) { foreach ($pt->repeater as $rp) { echo $someValue; echo $rp->field1; echo $rp->field2; echo $rp->field3; if( $rp->field1 >= $someValue && $rp->field2 <= $someValue ) { echo $rp->field3; } } } -
@dazzyweb - you're right, maybe the first thing we all need to do with new clients is to have a meeting where we explain these differences; I try and do this whenever possible, and it helps. And it's true what Joss says that most clients are completely in the dark about the world of web design, and the internet in general. This places a larger burden upon us web designers because of the training and support implications, and that's an area that i'm trying to deal with now, like for example marking up budgets to account for all of the question-answer, training sessions, and making docs...
-
The linchpin mentality would be espouse all possible solutions appropriate to the scope of the project, considering all elements including budget, time frame, intended audience type and size, target devices, developer's time resources, with the goal to ship it on time and on budget. Themeforest is a great resource for front end designs, and I use it when appropriate (and also codecanyon). But don't expect to get much in terms of support; also sometimes the technologies used are not quite up to date, and the css can be bloated. We all love bespoke–after all, the engine running the site is already as bespoke as it can get without writing your own CMS. But most clients I work with can't afford bespoke frontend and backend so a choice has to be made. I have a few "go-to" TF authors that are great both in terms of design and code quality. The clients usually pick the template by visiting TF. If this was my full time job, I would probably only do 100% bespoke front end because it would be more fun and engaging. But this is all relative- we're already abstracted a few levels away from the bottom with frameworks, css preprocessors, and CMFs... Nobody Cares How Hard You Worked
-
if you want to go further, you can use the nested accordion which allows for child accordions of the main topic; you would need to create child pages for each main subject; in that case your template might look like this: <?php $docs = $pages->get(4259); ?> <div id="docs"> <ul id="cbp-ntaccordion" class="cbp-ntaccordion"> <?php foreach($docs->children as $doc) { ?> <li> <h3 class="cbp-nttrigger"><?php echo $doc->title ?></h3> <div class="cbp-ntcontent"> <?php echo $doc->body;?> <?php if($doc->children->count()) { ?> <ul class="cbp-ntsubaccordion"> <?php foreach($doc->children as $child) { ?> <li> <h4 class="cbp-nttrigger"><?php echo $child->title?></h4> <div class="cbp-ntcontent"> <?php echo $child->body?> </div> </li> <?php } ?> </ul> <?php } ?> </div> </li> <?php } ?> </ul> </div> <script src="<?php echo $config->urls->templates ?>_admin_custom/js/jquery.cbpNTAccordion.min.js"></script> <script> $( function() { $( '#cbp-ntaccordion' ).cbpNTAccordion(); }); </script> in this code the sub-accordion is shown if there are child pages, and then it outputs the body of each child page in a sub-accordion, and it will end up looking something like this: a more advanced implementation with edit links and an add new doc for superusers: <?php $docs = $pages->get(4259); ?> <div id="docs"> <ul id="cbp-ntaccordion" class="cbp-ntaccordion"> <?php foreach($docs->children as $doc) { ?> <li> <h3 class="cbp-nttrigger"><?php echo $doc->title ?></h3> <div class="cbp-ntcontent"> <?php echo $doc->body;?> <?php if($user->hasRole('superuser')) { ?> <div style="float:right;font-size:11px;"> <a href="<?php echo $config->urls->admin?>page/edit/?id=<?php echo $doc->id?>">Edit: "<?php echo $doc->title?>"</a> </div><?php } ?> <?php if($doc->children->count()) { ?> <ul class="cbp-ntsubaccordion"> <?php foreach($doc->children as $child) { ?> <li> <h4 class="cbp-nttrigger"><?php echo $child->title?></h4> <div class="cbp-ntcontent"> <?php echo $child->body?> <?php if($user->hasRole('superuser')) { ?> <div style="float:right;font-size:11px;"> <a href="<?php echo $config->urls->admin?>page/edit/?id=<?php echo $child->id?>">Edit: "<?php echo $child->title?>"</a> </div><?php } ?> </div> </li> <?php } ?> </ul> <?php } ?> </div> </li> <?php } ?> </ul> <?php if($user->hasRole('superuser')) { ?> <div style="float:right;font-size:13px;"> <a href="<?php echo $config->urls->admin?>page/add/?parent_id=4259"> <button class="ui-button ui-widget ui-corner-all head_button_clone ui-state-default" name="button" value="Add New" type="button"><span class="ui-button-text"><i class="fa fa-plus-circle"></i> Add New Doc</span></button> </a> </div><?php } ?> </div> <script src="<?php echo $config->urls->templates ?>_admin_custom/js/jquery.cbpNTAccordion.min.js"></script> <script> $( function() { $( '#cbp-ntaccordion' ).cbpNTAccordion(); }); </script>