I have searched around a lot but I don't find any good information how too
add a custom field to Joomla article (com_content&view=edit). Just how you hack Joomla's core files to add own fields but its not an alternative for me.
I think the best way to do it is to create a own plugin, but im stuck here. I have created a plugin into group "system" but my plugins doesn't get triggered.
Does anyone know how I can solve this on a good way?
My plugin customfield.php:
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
class plgSystemCustomField extends JPlugin {
function onContentPrepareForm($form, $data)
{
echo "Trigger 1???";
if($form->getName() == 'com_content.article') {
JForm::addFormPath(dirname(__FILE__).'/form');
$form->loadFile('customfield', false);
print_r($form);
}
return true;
}
function onDisplay() {
echo "Trigger 2???";
}
}
One of Joomla's major weaknesses is the difficulty of adding custom fields. There are numerous discussions about this in various Joomla forums. Although it's not easy, the current solution is to use one of the "CCKs" or advanced form extensions, such as these: http://extensions.joomla.org/extensions/authoring-a-content/content-construction
Related
I want to create shortcodes system for my Laravel project to include a page in another page.
Anyone have a solution?
[include]test[/include] -> #include('test');
This package is probably what you're wanting.
Something like:
class IncludeShortcode {
public function register($shortcode, $content, $compiler, $name)
{
return view($content);
}
}
Shortcode::register('include', 'IncludeShortcode');
Not tested, but should get you going in the right direction.
an app I am creating needs to follow Companies, aside from users. And let the companies have their own activities. How is this configured in Laravel getStream. Seems the feeds are only for user types.
timelineFeed = FeedManager::getNewsFeed($user->id)['timeline'];
$aggregatedTimelineFeed = FeedManager::getNewsFeed($user->id)['timeline_aggregated'];
sample model i have is this:
namespace App;
use Illuminate\Database\Eloquent\Model;
class CompanyPost extends Model
{
use \GetStream\StreamLaravel\Eloquent\ActivityTrait;
public function company()
{
return $this->belongsTo('App\Company', 'company_id', 'id');
}
public function activityVerb()
{
return 'company_post';
}
public function activityActorMethodName()
{
return 'company';
}
}
but i have noticed the feed is still saved on the user activities instead of the company activities.
Thanks in advance guys.
Ian seems to have confused you with me in his link to the Github issue which brought this post to my attention.
The reason this is still showing up on the user feed is that this isn't a configurable option at least on a case by case (or model by model) level. You can override what Stream Laravel uses as the "user feed" in the main configuration but as far as I can tell you are stuck posting to the active logged in user's feed unless you build out the functionality yourself with the Stream-PHP libs and abstain from using the StreamLaravel Activity trait.
You can see here starting at Line: 73 of StreamLaravelManager.php what's happening when an activity is created.
public function activityCreated($instance)
{
$activity = $instance->createActivity();
$feed = $this->getFeed($this->userFeed, $instance->activityActorId());
$feed->addActivity($activity);
}
Unfortunately "$this->userFeed" ultimately is pulled from the configuration file and I don't think there is a way to override it.
Personally, I ran into this when creating "like" functionality. I didn't really want people to have to see what everyone "likes" on their timeline since most of it would be irrelevant and it would get cluttered fast so I ended up not even creating a "like" activity. Instead I'm only added it to a users notification feed when someone likes something of theirs. Of course this may not be desirable for everyone to handle it that way but I noticed you had the "like" activity in your screenshot so I figured I'd mention it.
Good luck on your app!
Our stream-laravel project has some documentation on how to change the model
class Pin extends Eloquent {
use GetStream\StreamLaravel\Eloquent\ActivityTrait;
public function author()
{
return $this->belongsTo('Author');
}
public function activityActorMethodName()
{
return 'author';
}
As far as letting volunteers follow companies and users, we have some documentation in the main README.
(edited to remove my mistaken github reference)
sorry for the late reply. I have managed to follow a company creating
a feed group:
company flat On
and the using sample code below to follow:
$feed = FeedManager::getClient()->feed('timeline', $user->id);
$feed->followFeed('company', $companyId);
Unfollow:
$feed->unfollowFeed('company', $companyId);
Add activity:
$companyFeed = FeedManager::getClient()->feed('company', $company->id);
$companyFeed->addActivity([
"actor" => "App\Company:{$company->id}",
"verb" => "company_post",
"object" => "App\CompanyPost:{$post->id}",
"foreign_id" => "App\CompanyPost:{$post->id}"
]);
i'm trying to introduce an additional step in the one step checkout process (at the start, just after login). This is on Magento v1.8 and the items being sold are virtual product types (therefore the only sections that should appear at checkout are: [new section], billing, payment, and order review.
I've had a look at a number of articles - this one being most suited to my needs (albeit written for v1.4 i think, and uses a the overloading of existing pages instead of writing a new module). I've also followed along with this article however it aims to introduce a module - something which I don't think is absolutely required for this. SO article Magento Adding Step to Onepage Checkout was also referenced.
My problem:
I have the additional step appearing on the OPC page, however the accordion which should be expanding the active section isn't. This is due to the CSS class active not being set, which is in turn not set since the new module is not marked as active.
My question:
What have I missed from the steps below to ensure that the new module is set as the ActiveStep?
What I've attempted to so far:
In short, I've introduced <?php echo $this->getActiveStep(); ?>statement on onepage.phtml and it's indicating that 'billing' is still the active page (the default first page).
I've made the following changes so far specifically around the ordering of pages:
added the new section (registerkids) to _getStepCodes() in abstract.php
return array('login', 'registerkids', 'billing', 'shipping', 'shipping_method', 'payment', 'review');
created a app/code/local file in Checkout/Block/Onepage/registerkids.php with
class Mage_Checkout_Block_Onepage_Registerkids extends Mage_Checkout_Block_Onepage_Abstract
{
protected function _construct()
{
$this->getCheckout()->setStepData('registerkids', array(
'label' => Mage::helper('checkout')->__('Assign your kids to the booking'),
'is_show' => $this->isShow()
));
if ($this->isCustomerLoggedIn()) {
$this->getCheckout()->setStepData('registerkids', 'allow', true);
}
parent::_construct();
}
}
removed the if ($this->isCustomerLoggedIn()) statement from Checkout\Block\Onepage\billing.php that sets the next step
updated Checkout\Model\Type\Onepage.php initCheckout() with
if (!($step==='login' || $customerSession->isLoggedIn() && $step==='registerkids')) {
$checkout->setStepData($step, 'allow', false); // where 'registerkids' used to say 'billing'
made the following changes to opcheckout.js -
this.steps = ['login', 'registerkids', 'billing', 'shipping', 'shipping_method', 'payment', 'review']; (added new section)
this.currentStep = 'registerkids';
updated setMethod: function() so that next section after login is this.gotoSection('registerkids', true);
updated template/persistent/checkout/onepage/login.phtml JS customMethod() to checkout.gotoSection('registerkids');
updated Checkout/Onepage.php getActiveStep() to return $this->isCustomerLoggedIn() ? 'registerkids' : 'login';
after quite a bit of investigation, the function that controls the initial Active step is:
public function getActiveStep()
{
return $this->isCustomerLoggedIn() ? 'yoursection' : 'login';
}
this can be found in Mage\Checkout\Block\Onepage.php, and the function that calls it from onepage.phtml is $this->getActiveStep()
The reason it wasn't working for me was that the file was in the wrong place. Working fine now.
Hope this helps someone
I'm working on custom blog based on CodeIgniter. Got some problems at the moment I've achieved url:
/blog/view/1/my-very-first-post
I'm not happy with that I'd like to get rid off id and "/view"
That's how my controller looks like:
function index($postId=null)
{
$this->view($postId=null);
}
function view($postId, $str_slug = '')
{
$data['title'] = ucfirst("Blog");
$data['post'] = $this->posts->get_posts($postId);
if($postId !== null)
{
$this->load->view('templates/head', $data);
$this->load->view('templates/header', $data);
$this->load->view('posts/single_view', $data);
$this->load->view('templates/footer',$data);
} else {
$this->load->view('templates/head', $data);
$this->load->view('templates/header', $data);
$this->load->view('posts/index', $data);
$this->load->view('templates/footer',$data);
}
$row = $this->db->get_where('posts', array('id' => $postId))->row();
if ($row and ! $str_slug) {
$str_slug = url_title($row->title, 'dash', TRUE);
redirect("blog/view/{$postId}/{$str_slug}");
}
}
What is the best way to achieve this?
Thanks!!
Adam
I think you're looking for the _remap() method. You can read more about it here: http://ellislab.com/codeigniter/user-guide/general/controllers.html#remapping
Your code would look something like below. You still need to implement the get_posts_by_slug() method if you still need it.
public function _remap($slug) {
$data['title'] = ucfirst("Blog");
$data['post'] = $this->posts->get_posts_by_slug($slug);
if($slug !== null)
{
$this->load->view('templates/head', $data);
$this->load->view('templates/header', $data);
$this->load->view('posts/single_view', $data);
$this->load->view('templates/footer',$data);
} else {
$this->load->view('templates/head', $data);
$this->load->view('templates/header', $data);
$this->load->view('posts/index', $data);
$this->load->view('templates/footer',$data);
}
$row = $this->db->get_where('posts', array('slug' => $slug))->row();
}
Update:
Hey #AdamLesniak - it's generally good design to store a permalink to a blog post or a news article, so that it's not dependent on the title or any other volatile data structure in order to still be accessible.
But for a different approach, personally, I really think this is a nice system:
http://localhost/blog/my-news-article-title-permalink/3
The main issue is that if you don't store the slug/permalink somewhere, then you're going to feel sad when somebody changes the title of an article. Example, my article called "Hello World First Blog Post", which is accessible at:
http://localhost/blog/hello-world-first-blog-post
Changes into "First post I ever made":
http://localhost/blog/first-post-i-ever-made
So what happens to the initial URL? It's no longer accessible - any user that comes on the website via a search engine, or through somebody's link will now no longer see your comment and will instead get a 404 page, which you want to avoid.
A problem with using permalinks on their own is that you need to make sure they're unique, and extra constraints need to be set in place for that.
There are a few tricks that you can do, but they all have their pitfalls. You can for instance use the system I've mentioned above, where you stick the unique identifier at the end of the URL:
http://localhost/blog/hello-world/3
And if the title changes, you don't really care, because you're not using the slug to make your searches, but instead, you're relying on the unique identifier.
http://localhost/blog/first-post-i-ever-made/3
However I've seen opinions that this sort of system is against the idea of an URL (Uniform Resource Locator). I've used it in back when I was starting out, and it proved to be a flexible system; it's definitely nice to experiment with at least.
BBC do a variant of the above, by keeping the category that an article belongs to and the unique identifier for the entry:
http://www.bbc.co.uk/news/business-24511283
Basically, they know that an article will never change its category, although it may change its title, so they just keep the general topic, which is business and the unique identifier 24511283.
In the end, what I suggest you do, as it's by far the most scalable solution is to just generate the following format:
http://localhost/blog/permalink/unique-id
The format above lets you have unique identifiers, which are important for guaranteeing singularity, and permalinks for all the search engine friendly-ness! Now if the title of the article changes, display the updated title to the user on the page, but don't do anything to the permalink, so that your URLs never change.
By also using IDs in the URL, you know for sure that you can use a permalink multiple times, and your system will still scale correctly.
I wrote a tutorial on this which may or may not help: http://www.rappasoft.com/tutorials/14-seo-friendly-links-with-codeigniter.html
I am using magento and it's built in functionality for adding products to google base. I would like to change it so that it uses the Short description as the Description in Google base. As opposed to the detailed description.
According to this Screencast you should be able to setup attribute attribute mappings. Is that not working for you?
Looking deeper, I don't have a google base account, so I can't test this, BUT, when I search through the Google Base module it looks like this is where it's grabbing the description
app/code/core/Mage/GoogleBase/Model/Service/Item.php
protected function _setUniversalData()
{
//...
if ($object->getDescription()) {
$content = $service->newContent()->setText( $object->getDescription() );
$entry->setContent($content);
}
//...
}
My general approach here would be to create an override for the _setUniversalData method on the Mage_GoogleBase_Model_Service_Item class that looks something like this
protected function _setUniversalData()
{
parent::_setUniversalData();
//your code to parse through this object, find the long desription,
//and replace with the short. The following is pseudo code and just
//a guess at what would work
$service = $this->getService();
$object = $this->getObject();
$entry = $this->getEntry();
$new_text = $object->getShortDescription(); //not sure on getter method
$content = $service->newContent()->setText( $new_text );
$entry->setContent($content);
return $this;
}
Good luck!
Figured out all I had to do was change:
if ($object->getDescription()) {
$content = $service->newContent()->setText( $object->getDescription() );
$entry->setContent($content);
}
to
if ($object->getDescription()) {
$content = $service->newContent()->setText( $object->getShortDescription() );
$entry->setContent($content);
}
in app/code/core/Mage/GoogleBase/Model/Service/Item.php
I eventually got the module to work and managed to fix all errors.
I put together short step-by-step guide on how to set up the Magento Google Base feed, including account configuration, adding the condition attribute & mapping attributes and publishing them here http://blog.pod1.com/e-commerce/magento-google-base-feed/
Magento 1.7.0.2 Google Shopping 1.7.0.0
app/code/core/Mage/GoogleShopping/Model/Attribute/Content.php
Change $description = $this->getGroupAttributeDescription();
In $description = $this->getGroupAttributeShortDescription();