-
Posts
11,176 -
Joined
-
Last visited
-
Days Won
371
Everything posted by adrian
-
Here's a relevant post: http://processwire.com/talk/topic/15-how-do-i-create-a-page-that-redirects-to-its-first-child/ You might also just consider disabling the parent page from being a link at all. Not sure what you are using to create your menu, but there are a few different ways to achieve this.
- 1 reply
-
- 1
-
-
A couple of relevant posts: http://processwire.com/talk/topic/4367-using-page-renderoptions-and-template-cache/ http://processwire.com/talk/topic/5394-page-renderfilename-confusion/
-
Thanks Ryan - very easy and effective. I didn't think about the rename function - was wondering how to rename the file as well as the pagefile in one easy process. I have pushed a new version to GitHub which uses this for API uploads and as a result can now support renaming files that are added from remote URLs. I think this should now work in all API / form scenarios, but if anyone comes across any issues, please let me know.
-
There are a few different ways to do this, including htaccess rewrites, but this code from willyc is a good option: http://processwire.com/talk/topic/1799-routes-and-rewriting-urls/ A few other posts worth reading: http://processwire.com/talk/topic/4847-redirect-in-htaccess/ http://processwire.com/talk/topic/3275-hide-parent-page-from-url/ http://processwire.com/talk/topic/4521-how-to-customize-urls/
-
Well, this will get you the full url to an image if you know the page id and its name: 'http://' . $config->httpHost . $config->urls->files . $page_id . $image_name Does the app know the url root to the page so you can build up the url to the image like that? Presumably this will never change, so you can hardcode it as: http://www.mydomain.com/site/assets/files/ and then append the page id and the image name. Maybe I am missing your point though.
-
Blog archive date not pulling from folder
adrian replied to melissa_boyle's topic in Getting Started
Hi Melissa, Just wanted to make sure you've seen this module: http://modules.processwire.com/modules/process-date-archiver/ Not sure if it behaves exactly the way you want, but if it does, it might save you re-inventing. -
Sorry for the slightly wrong steer. You should try is_object. But you'll also need things slightly different as well. This should work: function mymaketable($pageid){ $out = ''; $current_page = wire('pages')->get($pageid); $out .= "<table class='table table-striped'>"; foreach($current_page->fields as $field){ $items = ''; if (strpos($field,'DMCstats_') !== false) { if(is_object($current_page->$field)){ $out .= "<tr> <td>{$field->label}</td><td>"; foreach ($current_page->$field as $f) { $items .= "{$f->title}, "; } $out .= rtrim($items, ', '); }else{ $out .= "<tr> <td>{$field->label}</td> <td>{$current_page->$field}</td> </tr>"; } } } $out .= "</table>"; echo $out; } EDIT: just made a few fixes - I think it should be spot on now!
-
You might try making use of php's is_array to test the page field to decide if you need to foreach it and echo with commas between specialities etc, or just echo directly. Have a go and let us know if you need help. EDIT: Also, check out rtrim to remove the last comma at the end of your list. Also, just noticed that you have a typo: Average Fyling Time
-
What a waste of time, but I have managed to narrow down the debug accordion/source truncation issue to the ProcessPageDelete module and this code: public function addJavascript(HookEvent $event) { $js = ' <script type="text/javascript"> $(document).ready(function() { $("li.PageListActiondelete a").live("click", function(el){ if(!confirm("Are you sure?")) { return false; } }); }); </script>'; $event->return = str_ireplace("</head>", $js.'</head>', $event->return); } I am still not completely sure why it is breaking things and especially why only on one installation, but what I did was move that JS code into it's own file and call parent::init(); to have the module automatically load the ProcessPageDelete.js file. I'll submit a pull request to Nico.
-
Several options, but this post should get the juices flowing: http://processwire.com/talk/topic/2480-sort-children-by-the-sum-of-two-fields/
-
Speaking of the debug section, would you be opposed to this change so that it can be toggled closed again? $(document).ready(function() { $("#debug").accordion({ header: 'h3', heightStyle: 'content' }).hide(); $("#debug_toggle").click(function() { if ($('#debug').is(":hidden")) $("#debug").slideDown(); else $("#debug").slideUp(); var n = $(document).height(); $('html, body').animate({ scrollTop: n },'50'); return false; }); });
-
That's the weird thing though - the end of the debug.inc file looks perfect: <script type="text/javascript"> $(document).ready(function() { $("#debug").accordion({ header: 'h3', heightStyle: 'content' }).hide(); $("#debug_toggle").click(function() { $("#debug").slideDown(); $(this).hide(); var n = $(document).height(); $('html, body').animate({ scrollTop: n },'50'); return false; }); }); </script> Oh and I have already grabbed the very latest dev from today and deleted the old wire completely first. I'll keep investigating.
-
Ok, there is only one id of debug on the page. If I run that jquery from debug.inc in the console, it applies all that styling as it should. Turns out the page source was ending like this: <script type="text/javascript"> $(document).ready(function() { $("#debug").accordion({ header: 'h3', heightStyle: 'content' }).hide(); $("#debug_toggle").click(function() { $("#debug").slideD and generated source as: <script type="text/javascript"> $(document).ready(function() { $("#debug").accordion({ header: 'h3', heightStyle: 'content' }).hide(); $("#debug_toggle").click(function() { $("#debug").slideD</script></div></div><ul style="display: none;" tabindex="0" id="ui-id-1" class="ui-autocomplete ui-front ui-menu ui-widget ui-widget-content ui-corner-all"></ul></body> Weird!
-
Unfortunately there are no JS errors - not sure what the issue is here! I don't think I have seen "New Admin Theme" anywhere else either, but it had exactly the same config settings as Default Admin Theme" except that is was in the site modules. I did already get rid of it by uninstalling and deleting the folder from site/modules. Interestingly it couldn't be deleted using the new functionality via modules - the delete button wasn't there. The site/templates-admin was gone already and I believe wire was properly fully replaced. Anyway, I don't think this is likely to occur again with any luck.
-
I feel like I am interrupting a more important dialogue here, but another weird thing. I have some installs that look perfect, but at least one is not showing the debug accordion properly at all. The div is just: <div id="debug"> instead of: <div id="debug" class="ui-accordion ui-widget ui-helper-reset" role="tablist" style="display: block; overflow: hidden;"> which means everything loads completely open with no accordion styling at all. The broken one is a local install, but I also have a local one that is working fine.
-
Another quick comment. On one install that I have been updating, I ended up with two admin modules: "New Admin Theme" in the site modules section, as well as "Default Admin Theme" in the core section. I am sure this won't be an issue for new installs, but might be worth investigating for upgrades, although quite likely it won't happen anymore - I am guessing it was some specific recent version that installed the site "New Admin Theme" and this probably won't happen again, but thought I should report it just in case.
-
Small issue with the debug tools in the API variables section. Everything under the name column is white (not visible) due to: #footer a { color: white; }
-
Admin Page - "Recently Edited Articles" Link
adrian replied to Peter Falkenberg Brown's topic in Wishlist & Roadmap
Always such great videos kongondo, and a great module too. Just also thought it worth mentioning that several of the 3rd party themes out there all display last created / last edited in either a sidebar, or at the bottom of the page, eg: Moderna and MetroWire. It's often as simply done as something like this: foreach($pages->find('limit=5, sort=-modified') as $p){ if ($p->editable()) { echo "<li><a href='".$config->urls->admin."page/edit/?id={$p->id}'>". date('d.m.', $p->modified) ." " . $p->title . "</a></li>\n"; } } -
Something you could do in terms of creating the full table automatically: function maketable($pageid){ $current_page = wire('pages')->get($pageid); echo "<table>"; foreach($current_page->fields as $field){ if (strpos($field,'DMC_') !== false) { echo "<tr> <td>{$field->label}</td> <td>{$current_page->$field}</td> </tr>"; } } echo "</table>"; } maketable(xxxx); This will create the entire table for you from just the ID of the page and will make a table row for each field that contains "DMC_" in it's name.
-
Yeah I know but I can't see removing any of the options - I do like how configurable it is. Thanks for the width overwrite - it looks much better now.
-
Martijn has a very good point. I was off a little in my advice last night. In PW it is possible to specify a global label for a field, and also a label specific to a template. This is also true for the description and the column width, visibility etc. An even shorter way to get the context specific label would be simply: echo $page->fields->$field->label;
-
Hey Soma, Just noticed that with the new modal installation dialog, things can get a little crowded with the config settings for some modules, in particular my Custom Upload Names. I am wondering if you'd consider making the modal window larger - perhaps most of the window - maybe 95% width and 95% height - just enough of a reduction that it is still obvious that it's a popup. The alternative, in the case of my module anyway, might be to not float the settings side by side. If you think it's better to keep it small, then I'll look into that possibility.
-
You can get the label within your function like this: echo wire('fields')->$field->label; The details of the field (like the label) are part of the $fields array, and not the $pages array if that makes sense.
-
Try wrapping $current_page->$field in curly brackets like: {$current_page->$field}
-
davo, I am not sure what you are trying to achieve with $page->$current_page->$field, but you already have the page represented by the ID of $pageid in $current_page, so you should just be able to do: $current_page->$field Also, even if it was necessary, $page wouldn't work inside a function, you'd need wire('page'). Try that and let us know how you go. PS For debugging purposes, try this in your function: echo "label: $label<br />field: $field<br />pageid: $pageid"; just to make sure you have what you think you have in those variables.