Jump to content

photoman355

Members
  • Posts

    51
  • Joined

  • Last visited

Posts posted by photoman355

  1. Many thanks guys.  I knew about the prepend option but it doesn't solve the problem because then you get this structure in the nav:

    Root

    Home

    Page 1

    Page 2

    Root's name should be the name of the "Home" page.  I have come up with a solution for this which solves the menu problem however it doesn't create a permanent redirect for the root/home url and it breaks my scrollspy for some reason.  

    <?php
    	$root = $pages->get("/");
    	$child = $root->child();
    	if ($child) { echo "<li class='#{$child->name}'></a><a href='{$root->url}'><h1>{$child->title}</h1></a></li>";
    	} 
    	$root = $pages->get("/");
    	$first = $root->child();
    	$children = $root->children()->not($first);
    	foreach($children as $child) {
    		echo "<li class='#{$child->name} {$active}'></a><a href='{$child->url}'><h1>{$child->title}</h1></a></li>";
    	}
    ?>
    

    @kongondo's Your suggestion of putting the redirect in the Template for Home makes a lot of sense but I still need to pull in the code from Home to the Root page so would need to bear that in mind.  I'd definitely need the menu to tie up.  Can you suggest how I'd go about this?  From an SEO point of view is changing the menu enough to stop robots finding the root/Home url?

    @Wanze I know it's a bit of a strange setup.  I have several pages as content blocks so putting them in the backend structure as suggested could get messy from a client point of view.  If Root was Home it would look something like this:

    Root

        Block 1

        Block 2

        Block 3

        Page 1

            Block 1

            Block 2

        Page 2

            Block 1

        etc

  2. I have a slightly unusual setup where I'm using the first child of the root as my homepage like so:
     
    Root
          Home
          Page 2
          Page 3 
          etc
     
    This is presenting me with a slight problem in that I need the Home url in the navigation tree to redirect to Root.  Here's my navigation setup:
     
    <?php
    $root = $pages->get("/");
    $children = $root->children();
    foreach($children as $child) {
        echo "<li><a href='#{$child->name}'></a><a href='{$child->url}'><h1>{$child->title}</h1></a></li>";
    }
    ?>
    

    I'm sure there's a nice easy way to do this in PW, can anyone help?

    For data setup I have Home rendered in the Root page.  Looking at SEO would simply changing the menu structure be enough to stop robots indexing the root/Home url so that Home is seen as Root?  

  3. I've come across an error which is stopping fredi working with images in repeater fields.  I'm not quite sure why it's happening but this seems to be on all my templates with repeaters that contain image upload fields.

    As an example I have a carousel as a repeater (code below).  If the carousel is filled with images from the backend it works perfectly.  When I try to fill it with images using fredi on the frontend the edit modal pops up as expected and the "choose file" button for the field brings up my file explorer.  When I choose an image you can see that the image is trying to load but nothing happens.  

    The strange thing is this only happens with images.  I have other repeaters that contain both images and text and the text can be edited with fredi, just not the images.

    Is this a bug or do you have any suggestions to fix the error?

    Here's an example of my setup:

    Call fredi at the top of the template:

    <?php $fredi = $modules->get("Fredi");?> 

    Example of an image repeater I'm using:

    <?php 
        foreach($page->sliders as $k => $slider) {		
        $active = ($k == 0) ? " active" : "";		
        $image = $slider->image_single->size(660,220);
        echo  "<div class='item {$active}'>
        <img class='photo' src='{$image->url}' alt='{$image->description}' />
        </div>";
    }?> 
    

    Call the fredi edit link at the bottom of the template:

    <?php echo $fredi->render("sliders");?> 
    
  4. Hmm...not as simple as I thought.  

    @alanfluff Thanks I knew about the admin side limits but the problem with adding a limit to a field is that you have to create a separate field for each size of text you need. So for example if I was reusing <?=$page->body?> multiple times the text limits would have to be the same.

    @MatthewSchenker I had a read of the forum, really useful module.  In this case I can't use it as it uses the same way as Alan's method to set the limit. 

    @Soma This is exactly what I was after, many thanks. I noticed you wrote this as a function.  I take it this is pulled from a functions.php file much in the same way as wordpress? To save writing lots of code this makes a lot of sense.  If I wanted to apply the function to say the $page->body tag would I use a get call first or is there a better way?

  5. Thanks apeisa I didn't think of that.  For anyone else who's interested just add this to your header instead of the usual call.  Nice and simple. 

    <?php $fredi = $modules->get("Fredi");
       if ($user->isLoggedin()) {
       echo $fredi->renderScript();
       };?>
    

    Totally understand your reasons for making the column widths 100% as the original concept was about editing on a field by field basis.  My sites are built in blocks and I find myself grouping fields on a block by block basis as it's quicker for the client to edit and means I can output less edit links.  

    It would be great to have the markup available to target with css even if it's not used in your default css file but either way I'm very happy.  So good to have fredi.

    • Like 1
  6. @apesia I've been happily playing around with Fredi and have a small suggestion.  The echo $fredi->renderScript(); call is only required when the user is logged in but at the moment it's printed in the header regardless of whether the user is logged in or not.  

    I know this won't have a massive impact on page load speed but it adds another 2 http requests which aren't really necessary.  Just a thought.

    On a slightly different note I noticed that the admin field column widths are not reflected on the front end.  I'm not sure if this was on purpose to keep things responsive?

    Here's what's missing:

    class="InputfieldColumnWidth InputfieldColumnWidthFirst"   (These styles are in UI.css)
    

    and also the inline style that defines the width in the backend eg "width:20%".    

  7. Aha! That did it.  In the end I didn't need to write the code as above, all that's required is $fredi at the head of the child template like so:

    <?php $fredi = $modules->get("Fredi");?>
    

    Then just call as normal using 

    $fredi->render("heading|body|etc");
    

    Many thanks for your help apesia and for writing such a cool module  :)  

  8. Thanks diogo.  I tried your solution but I still can't get it to work.  When I add your code to the parent template file and view the result the page renders fine but there are no fredi links.  Here's the code I entered.

    <?php
    foreach($page->children as $child) {
        echo $fredi->render("body", $child);
        echo $child->render();
    }
    ?> 
    

    What I'd expect to happen is all the children that have a body field would be rendered with an edit link.  I tried various multiple field combinations but no joy.  I'm not quite sure why it's not working.  

    For simplicity sake let's say one of the child templates was just this:


    <div class="span4">
    <?=$page->body?>
    </div> 

    What's the best way to work with fredi using the example above.  Does it need to be called from the parent page template or can it be initialised in the child template itself?

  9. Thanks guys.  @adamspruijt, I never thought of adding blocks like that.  Definitely fast to deploy a site but one advantage of building with blocks as children is the blocks can be changed without touching the source.  I'm sure this could be set up via an of options page though.

    @diogo Looks like a fairly straightforward solution, look forward to testing it out.  Much appreciated.

  10. @apeisa This module is fantastic!!  It makes editing so much easier.  Thank you.

    I've been playing around with the various configuration options and have come across a problem, possibly because of the way my site is built.  I can get fredi working on pages that call in a header and footer but can't get it to work on my content blocks.  

    For setup I have a page with header and footer that pulls in children as content blocks like so:

    <?php foreach($page->children as $child) echo $child->render(); ?> 

    I tried targeting the child pages using $pages->get in the template file but it doesn't seem to work.  I'm not sure if this is because the blocks have no header and footer or if it's because fredi can't find them.  

    Is it possible to use fredi in this way or maybe to target the block template itself?

  11. Many thanks Ryan.  The 404 the page in question is a site-settings page that has no associated template file.  Would a processwire 404 from this page not be output as plain text anyway as there's no header and footer or would a 404 still show the admin header and footer?

    I'm sure you're right in saying it's mod_security anyway.  My hosting company are useless :)

  12. Thanks guys.  @adamspruijt I'm not quite sure what you mean by 

    If you use a different template on the pages that shouldn't be view-able (I assume everything but home), and that template does not have an associated file (example "basic-page" template has "basic-page.php") then the view button itself will not be shown. 

    Do you mean creating templates via admin without creating a physical template file?  All my blocks contain markup so they're built as separate eg block.php files.

    I'm not familiar with the repeater field technique for content blocks.  Can you explain a bit more?

    One workaround I thought of would be to add this to my admin template css which solves the problem up to a point.  

    .content .PageListActionView {
      display: none !important;
    }
    

     I was hoping there would be a nice simple way to handle it in Processwire. I know there's the redirect module but that's not ideal is it involves specifying each url and all I really need is a global rule that says - if child redirect to parent, or something like that.  

    @Macrura can you give me an example of how I would add a redirect to a template?

  13. I'm building a template for a one page website and have run into a small problem with the admin view page links.  

    Because my site is built with content blocks rather than pages there is no header and footer for each block, only the homepage needs to pull in the header and footer for the site.  As a result clicking to view a page in the admin shows the page content but with zero styling.  This is obviously not ideal for clients so I'd like to find a better solution.

    Here's a rough idea of the site structure:

        Home  (header & footer)

            Page 1

                Content Block 1

                Content Block 2

            Page 2

                Content Block 3 etc etc

    My page's use an anchor # for the url eg #contact so Ideally when the user clicks on the page they'd be redirected to that relevant anchor.  I know this might be complicated to achieve so all I really need to do is redirect all pages to the homepage (parent).  

    Any idea how I would go about this? 

  14. Aha that would make sense as my hosting company has been pretty poor of late.  Many thanks for the info Ryan.  How would I tell if this is definitely an Apache 404 vs a Processwire one?  

    I've been in touch and asked them to lighten up the security rules and they said they've changed them but I'm still having issues.  Before I go back to them I thought I'd try to disable mod_security using htaccess.  I added "SecFilterEngine Off" to htaccess but after adding it locks me out of my PW site.  I don't have much experience on the server side so I've probably tried to change completely the wrong setting.

    Is there a correct way to manually disable mod_security so I can check this is definitely the problem?  I have access to cpanel if that helps.

  15. @soma Yes I changed the default login from /processwire to /login mainly to make it more memorable for clients.

    For setup I have 6 textfields (all use the default settings) and the last textfield is what I'm having trouble with.  I did get a little further on today.  Tried repairing the database as Macrura suggested which all checked out fine.  I then returned to the admin and entered some different data with some success.  

    What I was entering before was a URL in the format "http://www.google.com" and saving the page throws an error.  I changed the entry to "www.google.com" and the page saves fine, no 404.  Very strange.  Next I changed the last field from a textfield to a URL.  Now when I go back to the admin page in question the URL field re-writes the last entry from "www.google.com" to  "http://www.google.com".  When I hit save I get the 404 again.

    It's clearly something to do with the "http://" part of the entry.  Soma you suggested this could be server security. Can you explain a bit more?

    Just something else to add.  I'm currently testing out the multisite install and this particular database is a clone from another of my PW sites.  I just exported the database from a master site and imported into a new database via phpmyadmin.  I don't know if this is significant or not?  

  16. @Soma I only thought the template code was at fault because everything worked up until I added the new code.

    @Macrura That's correct, entering data into any of the other text fields and saving works fine but for some strange reason entering data into social_upon and saving throws the 404.  This happens even if I empty one of the other fields and fill the social_upon field.  I've tried creating a new field with a different name but no joy.

    For URL's the page is at mydomain.com/login/page/edit/?id=1011.  When I hit save I get the 404 error message "The page you were looking for is not found.Please use our search engine or navigation above to find the page.".  The URL on that page is exactly the same.

    As I'm developing I still have the default site template and it's relevant files installed (my home.php has been modified).  My new template calls a different header, footer and template files. It's redirecting to the default install template page possibly because it's assigned as the default for 404's? 

    Modules wise I don't have many installed outside the default ones just, Fieldtype Crop Image, CK Editor, HTML Purifier, Modules Manager and Process Page Delete.

    Is there anything I should try?  

  17. I've just come across a really strange problem where processwire is throwing a 404 error after I enter a value into one of my fields.  I'm sure this is probably down to my code.  

    I have a set of fields that when a value is entered some output is echoed to my template.  Every field works as expected except the last field which throws the 404 after entering a value and saving the page.  

    Here's the code.

     <?php 
    $settings = $pages->get("/site-settings/");
    
    if ($settings->social_facebook) echo "<li><a class='icon-small small-icon-facebook' href='{$settings->social_facebook}' target='_blank'></a></li>";
    if ($settings->social_twitter) echo "<li><a class='icon-small small-icon-twitter' href='{$settings->social_twitter}' target='_blank'></a></li>";
    if ($settings->social_linkedin) echo "<li><a class='icon-small small-icon-linkedin' href='{$settings->social_linkedin}' target='_blank'></a></li>";
    if ($settings->social_youtube) echo "<li><a class='icon-small small-icon-youtube' href='{$settings->social_youtube}' target='_blank'></a></li>";
    if ($settings->social_picasa) echo "<li><a class='icon-small small-icon-picasa' href='{$settings->social_picasa}' target='_blank'></a></li>";
    if ($settings->social_upon) echo "<li><a class='icon-small small-icon-stumble' href='{$settings->social_upon}' target='_blank'></a></li>";
    ?>

    I'm guessing there's a better way to write this but not quite sure why it's throwing an error.  I've tried deleting and recreating the last field with a different name but it still throws the same error.

    Can anyone help?

  18. I have an area on my homepage that I want to print data based on a checkbox value in my site settings template.  When the box is checked I want to output some HTML.  I've tried various combinations of code but can't get it to work.  

    Here's what I have at the moment.

    <?php 
    
    $settings = $pages->find("/site-settings/");
    
    if ($settings->mycheckboxfield == 1) echo "<li>This</li>";
    ?>
    

    Any ideas?

  19. I've been testing out the multisite feature of processwire installing via option 1 in the docs.  I managed to get everything working by following the first option which requires installing a new version of PW and copying the files over to a site-mysite directory.  I'm now testing out the second option which just needs the site files copies to a site- directory and importing the DB from another installation using PhpMyAdmin.

    The installation worked fine but when I try to login to the admin the username and password I used from my clone site are not recognised.  I thought the password would pull over from the SQL database.  I'm sure this is something really simple but I'm scratching my head at the moment.

    Any ideas?

×
×
  • Create New...