OJS3 show latest journal articles and wordpress feeds in website home page

Hi everyone,

I want to display:

Latest 5 articles from every journals in the website
Recent 5 blog posts from wordpress

At the moment, I’ve added the links in theme/templates/frontend/pages/indexSite.tpl

I’ve tried WebFeed plugin which throws fatal error. How can I show these dynamically?

OJS 3.0.2
WordPress 4.8.1

Thanks

I have that in https://journal.fi, now I have promised to upload the site theme to github for two months now, hopefully I will have the time to do that finally during this week…

2 Likes

@ajnyga Journal looks great! Keep us updated.

Can you share some ideas about how you achieved this (latest articles)?

Are you using any plugins / override?

Thank you

I have the code in a theme plugin that I use for the site. Not too complicated. I can not access it at the moment, but will try to remember get back to you later today (Finnish time).

2 Likes

Thank you, will be waiting for your reply. Its the only pending task on the website, hope we can finish it soon with your help.

ah yes, sorry, I have been busy building a Finnish humanities portal. I will try, once again, today to finish cleaning the site themes and upload those to github.

I basically have this code in my main theme plugin file. It creates a variable, which it then sends to the site index template. About passing data to templastes, see https://pkp.gitbooks.io/pkp-theming-guide/content/en/advanced-custom-data.html

		// Start Latest issues
		$issues = array();
		$issueList = array();
		$volLabel = __('issue.vol');
		$numLabel = __('issue.no');
		
		$result = $issueDao->retrieve("SELECT issue_id FROM issues WHERE published = '1' AND access_status= '1' AND year != '0' ORDER BY date_published DESC LIMIT 6");
		
		while (!$result->EOF) {
			$resultRow = $result->GetRowAssoc(false);
			$issues[$resultRow['issue_id']] = $issueDao->getById($resultRow['issue_id']);
			$result->MoveNext();
		}
		$result->Close();

		foreach($issues as $issueId => $issue){
			
			$journal = $journalDao->getById($issue->getJournalId());
			$issueList[$issueId]['journal'] = $journal->getLocalizedName();
			$issueList[$issueId]['journalPath'] = $journal->getPath();
			
			if ($issue->getLocalizedCoverImageUrl()){
				$issueList[$issueId]['cover'] =  $issue->getLocalizedCoverImageUrl();
				$issueList[$issueId]['contain'] =  true;
			}	
			else{
				$issueList[$issueId]['cover'] =  $request->getBaseUrl()."/plugins/themes/myTheme/images/journalfi_default_cover.png";
			}
			
			
			$issueList[$issueId]['path'] =  $issue->getBestIssueId();
			
			$volume = $issue->getVolume();
			$number = $issue->getNumber();
			$year = $issue->getyear();
			
			$issueIdentification = "";
			if ($year != "") $issueIdentification = "(".$year.")".$issueIdentification;
			if ($number != "0") $issueIdentification = $numLabel." ".$number." ".$issueIdentification;
			if ($volume != "0") $issueIdentification = $volLabel." ".$volume." ".$issueIdentification;		
			
			$issueList[$issueId]['identification'] =  $issueIdentification;
			
			
			
		}
		$templateMgr->assign('issueList', $issueList);
		
		// End Latest issues

In the indexSite.tpl template I have:

<div class="tsv_issues">
{foreach from=$issueList item=issue}
	<div class="tsv_issue hvr-float">
		<a href="{url journal=$issue.journalPath page="issue" op="view" path=$issue.path}">
		<div class="tsv_issue_cover" style="background-image: url({$issue.cover}); {if $issue.contain}background-size: contain;{/if}"></div>
		<div class="tsv_issue_title">{$issue.journal}</div>
		<div class="tsv_issue_issue">{$issue.identification}</div>
		</a>
	</div>
	
{/foreach}	

And of course the necessary CSS which depends on the theme.

Now, I do not have an own code for fetching data from Wordpress, but maybe something like this would work: Use cURL and SimpleXML to retrieve and parse Wordpress RSS feed · GitHub

I mean you could change that code that it would build a similar array as above and the pass that array to the template and loop it through there with a similar loop as above.

1 Like

Hi, so I actually had an extra hour here to finish cleaning up the theme. There are still things I would need to do with this, a few things with the margins and responsive navigation menus, but I will probably finish those later this year.

I removed the images like logos, because I can not decide the licencing on those myself.

I would imagine that no one wants to copy the whole theme, but maybe the way the front page functions work will help someone to work on their own site themes.

2 Likes

How can I install the most read part in the index journal. I just have one journal. I have tried copying the php part and the indexsite code in the index journal file, but there it doesnt work. The site becomes a blank page.

Thank you very much @ajnyga will check it right away and update you soon.

Hi @ajnyga there is a small change, in indexSite.tpl line number 81 has extra {/if} which causes errors.

I will refer the code and implement in my theme

Thank you

Ok, thanks. I removed a few things that are very installation specific and not much use in the public repo. That was probably left out as a result. I will fix that!

Sorry I missed this earlier.

The blank page is probably due to an error, but it is hard to say what is causing the error without seeing the code in your theme plugin.

Hi Varshil,

You have to add the PHP code in your plugin theme inc.php

You can find it in root/plugins/themes/theme-name/theme-name-ThemePlugin.inc.php

I recommend you to install @ajnyga’s theme in local or development server and try. Then you can add the code to your theme.

Hope this helps

Yes, I do know that. I have been trying to do the same thing since last few
months. I know this code since 2-3 months, but every time I fail to
implement it. It basically doesnt get adjusted with my theme. Apart from
that, this is for the site and not for the index journal. I want it for an
index journal.

Hi, sorry for interrupt, is it possible for us to get single tsv journal template?