-
Posts
11,182 -
Joined
-
Last visited
-
Days Won
372
Everything posted by adrian
-
But if they are showing up on your reader page where you are using: echo $rss->render("http://undpw.local:8888/rss-vacancies"); I don't really understand, because they were not included in the XML output when viewing that page (http://undpw.local:8888/rss-vacancies) directly in the browser. Is that correct?
-
Ok, sorry, I thought you were using the feed generator module on the reader side for some reason. My mistake! It is all starting to make more sense now. Your code for MarkupLoadRSS (RSS Feed Loader) looks correct - sorry for the confusion there. So I guess the issue is still the generation of the feed at that url on the other site. I am at a loss for why it is showing selector-test (which it shouldn't) and nothing else. Strangely, when looking at the output for your reader page, it seems like it is actually showing results of pages from the PW default profile (eg: Child page example 1).
-
I know you are doing some unusual things with the include, but you still can't (unless there is something I am missing about the module), do: echo $rss->render("http://undpw.local:8888/rss-vacancies"); Try this instead: $rss->render($items); You shouldn't need to be echo'ing it either. At least try this standard approach first so you know the module is working as expected for you. Then perhaps you can figure out and better explain your other needs regarding the two site approach to all this.
-
I just re-read this bit: I think I get what you are trying to do, but I don't think this can be done with an include. You certainly can't call $rss->render on a url like that. It needs to be on a page array. I think you might be able to make it work with a screenscrape approach. There might be better ways, but I still don't understand the connection between the feeder and reader sites. Are these separate domains? Again I am not really sure what you are after, but simplepie (http://simplepie.org/) might be useful if you are trying to parse an RSS feed from one site and display the results on another. I think we still need more details to help you to figure out what you are trying to do.
-
The code to render the rss feed should be placed in a template/page called "rss" or similar, not in the template for a "normal" page that includes content that you want in the feed. Try that and let us know how you go.
-
Thanks Willy, I guess I am suggesting that Ryan remove the 255 limit since this is the default for the built in title field. Admittedly long titles like these are somewhat of an unusual case, but I have a few sites where the client is entering newspaper articles and scientific journal articles and the titles of these can be very long and I don't want them truncated. Ryan mentioned that the title should never be truncated, so just trying to ensure that this actually is the case by default.
-
Hey Ryan, Little bit of confusion on my part - I was using an older version of PW to test these changes. Now testing on dev, so this should all work fine. Regarding the title field - it is being truncated by the input field: <input id="Inputfield_title" class="required InputfieldMaxWidth" name="title" type="text" maxlength="255" /> Of course the DB field "data" is a full text, so it is not being truncated there, so firstly, can we remove the maxlength from the input field for the title? Also, there is a line in InputfieldPageTitle.js which is designed to truncate "var" to 128 characters. So, what I have done in InputfieldPageTitle.js is: //var val = $(this).val().substring(0, 128); var val = $(this).val(); Then in InputfieldPageName.js: //if(name.length > 128) name = name.substring(0, 128); if(name.length > 128) name = $.trim(name).substring(0, 128).split("-").slice(0, -1).join(" "); Does that all makes sense? Would you rather I submitted this as a pull request?
-
I can't say I understand why you are getting just those page being detected, especially the selector-test page. It also shouldn't be finding your /rss/ page in the pages list. Can you please show us exactly the selector you are using, along with a list of the pages that are returned with the selector test tool, or with the following, where {selector} is the selector code you are using: foreach(wire('pages')->find( {selector} ) as $page){ echo $page->title . '<br />'; } Maybe also post the complete code that you have in your function. Also, just for the fun of it, can you see what happens when you don't put the rss render code in a function. Maybe also write out the page tree for your vacancies pages, including the templates for the parent and child pages. I am sure we can figure it out.
-
If this is in a function like your previous post suggests, then you need to do: $items = wire('pages')->find ... If that is not the problem, what happens if you go back to back to the standard: $items = $pages->find("limit=10, sort=-modified"); Does it work like that? I am also wondering about "include=all". Do you really want items that have been added to the trash to show up in your feed? Do you have debug on? Any php errors?
-
Inside functions you need to use: wire('modules')-> Same goes for wire('pages') etc. This is due to variable scope issues: http://php.net/manual/en/language.variables.scope.php If you are ever writing a long function where one of the PW variables is used many times, you can always define it at the top of the function: eg: $modules = wire('modules');
-
Unable to log into admin ($session write issues) using vagrant
adrian replied to RodolfoDengo's topic in Dev Talk
Hi and welcome to PW. I haven't used vagrant, so I am not sure why there would be an issue with the PHP session path, but have you checked that PHP can write to: /vagrant/rhythm-site/site/assets/sessions -
It looks like he has taken care of the image stretching too much on the last line (or if there is only one image): https://github.com/ed-lea/jquery-collagePlus/commit/a31bd4e661f22eda169266e4b70c0212bae62211 Regarding the issue of waiting for all images to load before displaying anything can be taken care of by simply removing the: $(window).load(function () { in your plugin. Since all the images you are sending to it have width and height attributes, it doesn't need to actually load them all before starting to display them.
-
Hey Ryan, Using the following in InputfieldPageName.js seems to do the trick. if(name.length > 128) name = $.trim(title).substring(0, 128).trim(this); I was looking at InputfieldPageTitle.js and noticed that it doesn't actually do the truncate to 128. The browser is truncating to 255, but I think it is missing something like: $titleField.val(val).trigger('blur'); Also, I am not sure why, but the approach in the first code block above doesn't work for the title. Instead, I had to use: if($titleField.val().length > 128) val = $.trim($titleField.val()).substring(0, 128).split(" ").slice(0, -1).join(" "); But, I guess I am not sure what you actually want to do with the title field. Do you want it truncated to 255, or 128 to match the length of the name field? Some potentially more robust ways of doing this: https://github.com/micjamking/succinct/blob/master/jQuery.succinct.js https://gist.github.com/ChrisCinelli/5688048 Neither tested so far, as I don't think we need them. In particular, the succinct plugin was designed to deal with a couple of edge cases that I don't think should affect us: http://stackoverflow.com/questions/4637942/how-can-i-truncate-a-string-in-jquery
-
How to automatically set the value of a field?
adrian replied to bytesource's topic in API & Templates
Stefan, I believe the only reason why your code wasn't working is because you were using $this->addHookAfter. You'll notice that the code I put together uses $this->addHookBefore. You need to populate the value before rendering the field. As for the automatic filling error. Ryan has autocomplete="off" set for the form when editing an existing page. I have also seen this browser produced warning - it is not actually an error. Did you try the module I put together? You can easily change the fields that are being dynamically set to whatever you want. -
How to automatically set the value of a field?
adrian replied to bytesource's topic in API & Templates
Horst - I don't think that module will work for the title field, will it? Although I am still not sure if bytesource is looking to make the title field unique anyway - I guess we'll wait and see -
Hey Ryan, Some feedback from the dev on these issues: https://github.com/ed-lea/jquery-collagePlus/issues/6#issuecomment-22058143 https://github.com/ed-lea/jquery-collagePlus/issues/5
-
Thinking about a Like/Recommend button module
adrian replied to landitus's topic in Module/Plugin Development
I think this would actually be quite easy to implement, and yes you might well be able to make use of the code that is used for the module recommend button. In fact, here is the javascript that is used for that recommendation button: http://modules.processwire.com/site/modules/FieldtypeLikes/likes.js The "number_of_likes" field could have its visibility set to "Hidden, not shown in the editor". I actually think a new option to show field values, but make them read-only would be really nice in the admin (but I digress). You could make use of diogo's http://modules.processwire.com/modules/process-admin-custom-pages/ module to easily create the table of liked pages. Before we go reinventing things, let's see what Ryan says about handing over the php code that processes the ajax call from the likes.js file. -
How to automatically set the value of a field?
adrian replied to bytesource's topic in API & Templates
Just curious - you say that you want to make the title field unique, but in your code you are trying to set the value of the invoice_number field. This should do what you want, assuming you actually want to set the title field. <?php class MarkupTitleField extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'Markup Title Field', 'version' => 100, 'summary' => 'Set the title field to predefined value', 'singular' => true, 'autoload' => true, ); } public function init() { // add before-hook to the inputfield render method $this->addHookBefore("Inputfield::render", $this, "renderField"); } public function renderField(HookEvent $event) { // // get the current field $field = $event->object; if(($field->name == 'title' || $field->name == '_pw_page_name') && $field->value == '' ) { $last_page_id = wire('pages')->get("include=all,sort=-id")->id; $id = date("Y") . "/" . ($last_page_id+1); // example for a possible id value $field->set('value', $id); } } } Edited code to get the id of the page that is about to be created. Not sure if this is completely robust. You might want to consider a different unique identifier. -
Glad you got it working. Have you seen the API cheatsheet? http://cheatsheet.processwire.com/ path vs url is explained there for use in both $page-> and also $file-> Your best way to really figure some of this stuff out is to echo the results to the page. echo 'url: ' . $child->webfont_archive->url . '<br />path: ' . $child->webfont_archive->path; That way you can see exactly what is being returned.
-
Welcome to PW! Try using "->path" instead of "->url" as you need the full path to the file on the server when using include. That said, do you really want to "include" the stylesheet? Do you simply want: <link rel="stylesheet" href="'.$stylesheet.'" type="text/css">
-
Glad you found a solution. By chance, do the links from the slider images go to other pages on your site? Maybe they don't, but if by chance that is the case the approach I use is a single image field in the template for the pages you want to link to. Then you can do something like: $out .= ' <ul class="slideshow">'; foreach($pages->find('template=basic-page|another-template, slider_image!='', limit=4') as $slider){ $out .= '<a href="'.$slider->path.'"><li><img src="'.$slider->slider_image->url.'" /></li></a>'; } $out .= ' </ul>';
-
Well as you suggested, that is more of a challenge and I expect to do it nicely would require a module to add an additional field to the image. Ryan provides the code to do this here: http://processwire.com/talk/topic/417-extending-image-field/ A cheat's way out would be to use the description field, for both parts. This is very hackish, but will work. You could split the description field with a delimiter - maybe a pipe - eg: this is the description|http://link.tothe.image.com/ The you could use something like: $description_link = explode("|", $image->description); $description = $description_link[0]; $link = $description_link[1]; Depending on the client this might be too confusing for them to manage.
-
Well, depending on your needs, if you are setting up a gallery of images, you could have a page tree like this: Gallery --Nature --People ----Photo1 ----Photo2 --Action The template for the pages that contain the individual photos (eg Photo1, Photo2) could have the following fields: -Title (obviously as this is required) -Link (this is the field you are looking for) -Photographer -Date photo taken -Location -ETC Of course this structure may be overkill for your needs, but works really well if you want a gallery type setup, so hopefully this might be of some help.
-
Thanks Ryan - that works perfectly and makes total sense.
-
Hey Macrura, Thanks for the suggestions. Lots of simple modules ways of doing this - could probably even override the default name on save, but I was hoping Ryan might consider it a useful addition to the core. I am not too worried about it for my needs, but I think it would be a nice refinement still.