• Hi, I’ve been handed the task of inserting preview descriptions into each of the portfolio cards. Goal is to have a limited number of characters of the full description that you would see if clicking on the portfolio card.

    The site administrator reached out to portfolio software provider but their answer missed the mark. Their fix would only show the description if the card is hovered. See below.

    Support:
    You can do that by using the “Tiles Carousel Portfolios” element and turn the “Insert portfolio meta” option on from the left-hand side panel on the layout tab. In this case, when you hover over the picture you will see the overview description.

    If there is a way that I can do this with customer Javascript that would be fine, but I would still need to grab the data.

    • This topic was modified 4 years, 3 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator bcworkz

    (@bcworkz)

    You could use JS to insert data. It can get data through the REST API. You’re better off adding an excerpt as the page is output from PHP. It looks like the portfolio tiles are generated from a normal theme template and are CSS styled to appear as tiles. If so, you can override that template from a child theme where your version includes a description excerpt as part of the output.

    If the template is coming from a plugin, you can override which template is used through the “template_include” filter. Copy the applicable template to your child theme or custom plugin. Modify as desired, then return the path to your template from the filter callback.

    Thread Starter lgehrig4

    (@lgehrig4)

    The grid template is from the Phlox theme. I made a copy of the page and added JS to insert the excerpt. Right now I’m just loading dummy text until I figure out how to dynamically add the data.

    Given what I just said which method do you think would be best for me? I just need the data at this point. I’m sorry but can you explain the REST API method a little further. I’m fairly new to this.

    Thank you

    Moderator bcworkz

    (@bcworkz)

    IMO you’re better off managing this with PHP prior to output, but if you’re more comfortable with JS it’s a reasonable alternative. The main drawback to JS is it’ll slow the page load speed.

    The REST API is a useful alternative to Ajax. It provides a standardized protocol for fetching data and saves you from needing to write server side Ajax handler code for many situations. Your script makes a normal request to a specific URL and gets a JSON response back.
    https://developer.www.ads-software.com/rest-api/

    Aside from Ajax or the API, the other way to pass data to JS is through wp_localize_script() where you’d compile the data with PHP, then the function outputs a script block with a JS object declaration comprised of the data compiled by PHP. If you’re going to do it this way, I think you may as well send the data where it belongs as part of the template output instead.

    In summary, if you’re not going to go the PHP route, the API is your best alternative for getting data to your JS.

    Thread Starter lgehrig4

    (@lgehrig4)

    thank you for your help @bcworkz !

    One more question, if I go the PHP route, how would I access the PHP files on this site? So far my experience with WordPress is to created sites with themes or custom themes on a local server (MAMP). I’ve never actually work with the PHP files on a site that is live. Not sure they would want my to try either.

    Moderator bcworkz

    (@bcworkz)

    WP has theme and plugin editors, but you cannot add new files. Additionally, there is no way to recover from a silly error if you were to edit an active theme or plugin and crash the site. While there are some safeguards to prevent this from happening, it’s good practice to never edit an active module, always switch theme or deactivate a plugin before editing. If you introduce an error then, the faulty module cannot be activated and the site remains operational. It is possible for site owners to disable the editors. Additionally, your WP user may not have adequate permissions (“capabilities” in WP lingo) to use the editors.

    Ideally, you should have FTP access to the WP installation. Then you can easily make backups before editing and can easily recover should you accidentally introduce an error. Some clients are understandably reluctant to grant FTP access to consultants they do not have full confidence in. Having a written contract that outlines risks, rewards, and liabilities and includes full IRL contact info should give them some confidence. Personally, I always require FTP credentials as part of the contract. Illustrating the relative risks between having their site crash due to lack of FTP access vs. having to change a password if the relationship sours might help convince them. Some may be aware of “backdoors” and that changing a password doesn’t fully protect them. Knowing how to physically find you with IRL contact info should help assuage their fear.

    Do as much development work offline in your local MAMP as you can. You can replicate their theme and plugins on one of your MAMP sites. Either export some of their SQL data or create some dummy data, enough to fill a page’s worth of tiles. For significant work which will require client review prior to launch, you’ll want to set up a staging site which they can access for review. The staging site can be migrated to production after final approval. While there is little downside to introducing errors on a staging site, I still prefer to work locally and only move my work to staging when it’s nearly complete.

    Thread Starter lgehrig4

    (@lgehrig4)

    @bcworkz Lots of good information here and much of what I needed. Thank you!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Editing Portfolio Tiles / Cards’ is closed to new replies.