Jump to content

louisstephens

Members
  • Posts

    516
  • Joined

  • Last visited

Posts posted by louisstephens

  1. 2 hours ago, wbmnfktr said:

    There are so many ways in ProcessWire to do or save things.

    Depending on your background and history with ProcessWire you will find other ways or solutions.

    I know recipe-collectors that would only need two fields. A title and a textarea.

    I personally would go a more abstract way to be able to much more and other things.

    • Template: Recipe
      • Fields:
        • title (text)
        • summary/introduction (textarea)
        • preparation (textarea)
        • ingredients (repeater)
          • Fields:
            • ingredient (page reference - pages with template ingredient)
            • amount (int or text)
            • unit (select options - grams, cups, liters, hint)
        • images (image)
    • Template: Ingredient
      • Fields:
        • title

    With that setup I can easily collect all my recipes, create a list of all ingredients I need for all of my recipes. Can look for recipes with a special ingredient and so on.

    I actually did exactly as wbmnfktr suggested in a previous project (still in development). At first I was a bit hesitant of having to create new ingredients every time I wanted to add a new unique recipe, but the pros quickly outweighed the cons. It makes filtering on the front end a lot better/easier, as well as makes new recipes easier.

    • Like 1
  2. So I was tinkering around with the "select fields" field type and added it to a repeater. My thoughts were I could have a user select a field (textarea, text, etc etc) that I defined and give it a name (another field in the repeater) and create their own form on the page. To be honest, I am now a little lost with rendering the form and mailing the results as potentially the form will be unique and custom every time.  The only way I know to handle the output is by going about it this way:

    $forms = $page->form_select_fields;
    foreach($forms as $form) {
        if($form->name === "form_input") {
            //output input with custom name
        }
        elseif($form->name === "form_textarea") {
            //output input with custom name
        }
    }

    Is there a better way to go about rendering the elements from the repeater? As far as the custom sending goes, I am really at a loss since it would be pretty dynamic. Has anyone used this type of approach, and if so, how did you handle this without going insane?

  3. I have noticed this for awhile now. I guess I just always assumed that it "opens" the page tree for what you clicked on:

    - Parent Page (id:1)
    	-- Sub Page (id:2 - has 4 children)
    	-- Sub Page (id:3)
    		--- Sub Sub Page (id: 5 - currently open)
    	-- Sub Page (id:4)

    If you were on the "Sub Sub" page of id 3 and clicked on the Sub page with id of 2, it would "open up the tree on id 2 and collapse the rest of the tree. Well, that has been how it has been for me.

  4. So I have been diving into hooks lately, and I am enjoying them thus far. However, I guess I am a bit stumped on how to achieve what I want too. I am trying to set up a hook that would create a new child page when the parent page is saved. However, when you save the parent page a second time, I just need to update the child page without creating multiple child pages. What would be the best way to go about this?

    So after rereading my post, I believe it is a bit vague so I will try to explain more. 

    The Goal:

    1. Create a page with a template "one".
    2. Once the page is created/saved => create a new child page with the template of "two"
    3. If the parent is saved anytime after, do nothing to the child page (limit the parent page to one child page)

    The parent page is really just being used to output content, whereas the child page is being used to pull out the some fields from the parent to be used elsewhere. I might have made this too complicated in my head.

  5. If you look in that specific file, do you see the following:

    
    /**
     * ProcessWire namespace aware version of PHP's class_parents() function
     * 
     * Returns associative array where array keys are full namespaced class name, and 
     * values are the non-namespaced classname.
     *
     * @param string|object $className
     * @param bool $autoload
     * @return array
     *
     */
    function wireClassParents($className, $autoload = true) {
    	if(is_object($className)) {
    		$parents = class_parents($className, $autoload);
    	} else {
    		$className = wireClassName($className, true);
    		if(!class_exists($className, false)) {
    			$_className = wireClassName($className, false);
    			if(class_exists("\\$_className")) $className = $_className;
    		}
    		$parents = class_parents(ltrim($className, "\\"), $autoload);
    	}
    	$a = array();
    	if(is_array($parents)) foreach($parents as $k => $v) {
    		$v = wireClassName($k, false);
    		$a[$k] = $v; // values have no namespace
    	}
    	return $a; 
    }

     

  6. 41 minutes ago, kongondo said:

    I've been debating whether to do markdown docs (Docsify or variants) hosted on GitHub for my pro modules but the private repos thing always held me back. Does anyone know whether a repo can be private but its related wiki or GitHub pages is public?

    As far as I can tell, it might not be possible yet. There seems be some "work arounds" that can be found here:

    https://stackoverflow.com/questions/30121969/making-a-private-githubs-wiki-public

    https://help.github.com/articles/changing-access-permissions-for-wikis/ (though I am not sure what can truly be done here, as I dont have github pro account. With the "free" private repo, you lose access to wikis)

    • Like 2
  7. From my last post, I was given a good idea on how to count the repeater items, and it worked wonderfully. I got my code working well and the columns (based on the count) all work well as well. Now, I have a head scratcher on my hands. 

    <?php
    	$buttonsIncluded = $page->special_custom_buttons->find('special_custom_buttons_include=1');
    	$buttonsIncludedCount = count($buttonsIncluded);
    	$buttonsIncludedCountAdditional = $buttonsIncludedCount +1;
    	echo $buttonsIncludedCount;
    ?>
    
    <div class="row">
    	<?php foreach($buttonsIncluded as $button): ?>
    	<?php if($button->custom_buttons_include): ?>
    		<?php if($buttonsIncludedCountAdditional == 2): ?>
    			<div class="col-6">
    				<a href=""><?php echo $button->custom_buttons_text; ?></a>
    			</div>
    		<?php elseif($buttonsIncludedCountAdditional == 3): ?>
    			<div class="col-4">
    				<a href=""><?php echo $button->custom_buttons_text; ?></a>
    			</div>
    		<?php elseif($buttonsIncludedCountAdditional == 4): ?>
    			<div class="col-3">
    				<a href=""><?php echo $button->custom_buttons_text; ?></a>
    			</div>
    
    		<?php endif; ?>
    	<?php endif; ?>
    	<?php endforeach; ?>
    </div>

    All of this is included in a larger foreach statement that is pulling in other data (like body copy etc etc) from a Page Table field. As you can see in my code above, I am adding "1" to the count, so I can have space in the grid layout for a new button.

    So, right now: it looks something like: 

    [repeater button]		[repeater button]		[repeater button]		[space for new button]

    What I really need to do is to pull in the button from the Page Table and add it into the new space so it looks like:

    [repeater button]		[repeater button]		[repeater button]		[button from Page Table]

    Is this even possible todo, or is there a better way to go about this? 

     

    *Edit*

    So, I really just overlooked something quite easy here. Since the grid is based on 12 columns, I could just take 12 and divide by $buttonsIncludedCountAdditional which would give me the remaining col width to use outside the foreach loop. I was trying to make this too complicated.

  8. So I don't know how many have noticed yet, but Youtube has depreciated "rel=0" at the end of the embedded url in September 2018. For some reason, I just noticed today on a site I was working on. If you do not use the rel, you will get related videos across youtube, but if you use it, you will only get related videos from the same channel. Just wanted to share in case people did not know and they needed to make a change on whatever they were working on.

    • Like 2
  9. I currently use the Cobalt2 Theme by Wes Bos, and I like it thus far. I believe in his themes he uses a paid font for functions etc, so I found something similar to use in my own:

    1764494338_ScreenShot2018-12-28at8_38_58AM.png.8aca5ff682495ea80162b0099e164b7f.png

    It took me a few minutes to get use to the new font, but I like it a lot now. To me the theme is a nice alternative to the dark theme that I use to love so much. 

    • Like 1
  10. Hey Leftfield, it might help us better answer your question if you can describe in more detail your current template set up. For example, I use a template structure where the head is included into every template utilizing 

    <?php include("./inc/header.php"); ?>

    This way, I call some global settings in the head, and it is included everywhere. However, some people use the delayed output approach. 

  11. Hey dreerr, are you currently viewing the admin on mobile? I ask only because in your screenshot, the tab looks to about about 50%. From my understanding, if the width of the fields/container are 50% on mobile (or smaller devices), the fields will collapse and stack accordingly.

  12. From what I understand, you could create/publish pages regardless of roles/permissions. However, if you were to wrap the page creation in an if statement like :

    if($user->hasPermission('permission-name', $page)) {
      // user has this permission, for this $page
    }

    then that person with the permission could perform whatever action you created.
     

    • Like 2
×
×
  • Create New...