Jump to content

Lance O.

Members
  • Posts

    371
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by Lance O.

  1. Thanks @diogo, @ryan, @JeffS, and @Macrura73. I appreciate the help.

    I've tried the suggestions here, as well as many of my own, but still no luck. These are two solutions that seem to work, but are more verbose:

    $first = true;
    foreach ( $page->featured_project->images as $image ) {
    	if ( $first ) {
    		$thumb = $image->image_field->size( 100, 100 );
    		echo '<img src="' . $thumb->url . '" alt="' . $thumb->description . '" width="' . $thumb->width() . '" height="' . $thumb->height() . '">';
    		$first = false;
    	} else {
    	}
    }

    Another solution:

    $i = 0;
    foreach ( $page->featured_project->images as $image ) {
    	if ( $i == 0 ) {
    		$thumb = $image->image_field->size( 100, 100 );
    		echo '<img src="' . $thumb->url . '" alt="' . $thumb->description . '" width="' . $thumb->width() . '" height="' . $thumb->height() . '">';
    	}
    	$i++;
    }

    To summarize, the Home page includes a field called "featured_project." In these solutions, the "featured_project" field type is "Page" and is set to "Single page (Page) or empty page (NullPage) when none selected" on the field's Details tab. A featured project contains a repeater field named "images" and contains an image field named "image_field."

  2. @JeffS

    The field type for "featured_project" is set to: Multiple pages (PageArray).

    Note that for the solutions posted below, the field type for "featured_project" was set to Single page (Page) or empty page (NullPage) when none selected.

    Here's the set up:

    Home page

    -- featured_project (Page field)

    Project page

    -- images (repeater field)

    ---- image_field (image field)

  3. I want to resize an image that is included in a selected featured project as referenced from a Home page.

    The "Featured Project" field found on the Home page is using a Page type. The "Images" field included in the "Featured Project" is a repeater field that includes an Image field.

    How do I access the first image in the "Images" field and also resize the image?

    This works and returns the ID of the image:

    $img = $page->featured_project->images->first();

    but this doesn't work to resize the image:

    $img = $page->featured_project->images->first();
    $thumbnail = $img->size(236,225);
    

    Nor does this:

    $img = $page->featured_project->images->first()->size(236,225);

    Any insight is appreciated!

  4. Is there a more efficient way to code this using children($selector)?:

    $ancestor = $pages->get( 1134 ); // Get the Section 1 page
    $find = $pages->find( "parent=$ancestor->children, template=subcategory" );
    $assets = $pages->find( "tag=$find, sort=title" );
    if ( count( $assets ) ) {
    foreach ( $assets as $asset ) {
    	echo "<div class='asset'><a href='{$asset->url}'>{$asset->title}</a></div>";
    }
    }

    The page hierarchy looks like this:

    - Browse (the page that this code resides on)
       -- Section 1 (the ancestor page with id of 1134)
           --- Category 1
               ---- Subcategory 1
               ---- Subcategory 2
           --- Category 2
               ---- Subcategory 3
               ---- Subcategory 4
       -- Section 2
           --- Category 3
               ---- Subcategory 5
               ---- Subcategory 6
           --- Category 4
               ---- Subcategory 7
               ---- Subcategory 8
    - Assets
       -- Asset 1 (tag = id of Subcategory 1)
       -- Asset 2 (tag = id of Subcategory 2)
       -- Asset 3 (tag = id of Subcategory 3)
       -- Asset 4 (tag = id of Subcategory 4)
    

    I want to display all of the assets where tag = id of Subcategory 1, Subcategory 2, Subcategory 3, and Subcategory 4. In other words, I want to display all assets that are "included" in Section 1.

  5. At some point with all of my projects, the client will ask for an image to be replaced. But the image description rarely needs to be updated when the image is replaced. (For example, the client may wish for the image to be cropped in a different way.)

    Unfortunately, when replacing an image in PW, the description is deleted. If the client isn't aware that it will be deleted, it leads to frustrated clients and missing data. And if a large number of images need to be replaced, it is cumbersome to copy the description and paste it back into the field when the image is replaced.

    In a future version of PW, I've love to see the description remain untouched when an image is replaced.

  6. I'm working on a portfolio site where I want the following public site structure that organizes projects by categories:

    /work/ -> Listing of all projects

    /work/strategy/ -> Listing of strategy projects

    /work/user-experience/ -> Listing of user experience projects

    /work/development/ -> Listing of development projects

    Then, projects would be structured as:

    /work/project-name-a/

    /work/project-name-d/

    /work/project-name-c/

    /work/project-name-e/ ...

    My question is, what is the best field type to use to categorize projects? Should I use a Page with Multiple pages (PageArray)?

    I guess my confusion is moving from WordPress categories/taxonomies to PW's use of pages. Any insight would be appreciated.

  7. I have a client that wants the following functionality for an intranet site:

    1. The intranet must be password protected. Each employee must have their own individual username and password. There may be a total of 100 employees who would have access to the site.
    2. A small group of employees need to have full admin rights to add, modify, and delete pages, posts, and images. They must also be able to add and delete non-admin employees.
    3. Admins and non-admin employees must be able to modify their personal profile on the site. Profile information may contain name, email, password, bio, photo(s), and links to external social media sites. The login and profile pages should *not* look like the PW admin.
    4. Employee profile pages should be available to other employees. In other words, the site should support an employee directory.
    5. Employees must be able to comment on existing pages and posts on the site. (Not sure how to implement this requirement.)
    6. Images that are uploaded should be viewable in a slideshow gallery format.

    I've developed one site in PW so far, but nothing like the above requirements. I'm 90% confident that PW can handle these requirements, but thought I'd check with the PW community first before making a commitment to using PW.

    I could build the site in WordPress, but it may be more work than to build it in PW. If someone else has built a similar site, I am interested in hearing about your experience.

×
×
  • Create New...