-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single project view #140
Single project view #140
Changes from all commits
0297aac
37e97c4
4dfbf7f
09b6936
b417fd5
44ef1ff
554eded
8a616c2
fd762e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -409,4 +409,4 @@ function largo_excerpt( $the_post = null, $sentence_count = 5, $use_more = null, | |
|
||
return $output; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,54 @@ | ||
var $ = jQuery; | ||
$(document).ready(function(){ | ||
|
||
current_ltw_projects_load_param_project_if_exists(); | ||
|
||
$( ".projects-list article .entry-title a" ).click(function(e){ | ||
e.preventDefault(); | ||
var post_id = $(this).data("post-id"); | ||
current_ltw_projects_load_single_project(post_id); | ||
}); | ||
|
||
}); | ||
|
||
/** | ||
* Function to load the single project partial for whatever project | ||
* is provided. | ||
* | ||
* @param int post_id The id of the project we want to load | ||
*/ | ||
function current_ltw_projects_load_single_project( post_id ) { | ||
|
||
// give a reassuring "loading" notice | ||
$(".projects-single-holder").html("Loading project..."); | ||
|
||
// actually load the single project | ||
$(".projects-single-holder").load(ajax_object.ajax_url+"?action=load_more_post&post_id="+post_id); | ||
|
||
// return and let's be happy | ||
return; | ||
|
||
} | ||
|
||
/** | ||
* Fires on page load to check if a post_id query param is set | ||
* If it is set, attemps to load the specified project by the ID given | ||
*/ | ||
function current_ltw_projects_load_param_project_if_exists() { | ||
|
||
// find all current query params | ||
var get_url_params = new URLSearchParams(window.location.search); | ||
|
||
// if the post id query param exists, let's use it | ||
if(get_url_params.get('project_id') || Number.isInteger(get_url_params.get('project_id'))) { | ||
|
||
var post_id = get_url_params.get('project_id'); | ||
|
||
// actually try and load the project | ||
current_ltw_projects_load_single_project( post_id ); | ||
|
||
return; | ||
|
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ | |
<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix projects-list-item'); ?>> | ||
|
||
<?php | ||
|
||
echo '<div class="' . $entry_classes . '">'; | ||
|
||
if ( largo_has_categories_or_tags() ) { | ||
|
@@ -43,15 +44,15 @@ | |
?> | ||
|
||
<h2 class="entry-title"> | ||
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute( array( 'before' => __( 'Permalink to', 'largo' ) . ' ' ) )?>" rel="bookmark"><?php the_title(); ?></a> | ||
<a href="?project_id=<?php echo get_the_ID(); ?>" title="<?php the_title_attribute( array( 'before' => __( 'Permalink to', 'largo' ) . ' ' ) )?>" rel="bookmark" data-post-id="<?php echo get_the_ID(); ?>"><?php the_title(); ?></a> | ||
</h2> | ||
|
||
<?php | ||
// we may need to redo these links as search query params instead | ||
$status = get_the_terms( get_the_ID(), 'project-status' ); | ||
$categories = get_the_terms( get_the_ID(), 'project-category' ); | ||
// @todo this throws errors when no terms are found for this type of post | ||
if ( is_array( $status) && is_array( $status ) ) { | ||
if ( is_array( $status) && is_array( $categories ) ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the catch. 👍 |
||
$terms = array_merge( $status, $categories ); | ||
} else if ( is_array( $status ) ) { | ||
$terms = $status; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider https://current.test/ltw-test-page/ and the per-project page https://current.test/ltw-test-page/?project_id=3251741:
On page load, https://current.test/ltw-test-page/ displays in the single-project area the final post from the queue, which is the last item in the post list.
The DOM looks like this:
Styles on
.projects-single-holder
give the project a single black outline.Clicking on the last item in the list loads the post:
The post now has a double black outline.
Loading the project-specific URL https://current.test/ltw-test-page/?project_id=3251741 means that that project is, upon page load, queried for by JS and then loaded by JS:
The post now has a double black outline.
In conclusion: loading the project via JS means that we get an extra
div.projects-single-holder
.partials/project-single-holder.php
into two files: the holder and the held.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benlk I noticed that too and wanted to hear your opinion on what you think would be best. I think splitting up the "holder" and the "held" sounds like a viable solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#140 (comment) explores a little more the holder/held distinction; I think what we'd end up with is:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@benlk 8a616c2 starts the implementation of that structure