Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8596179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:36:53+00:00 2026-06-12T00:36:53+00:00

I have created my own component. When I add a new record to my

  • 0

I have created my own component. When I add a new record to my component, I also want it to create a new article in joomla (i.e. using com_content).

I found this on stack overflow Programmatically adding an article to Joomla which explains how to do it. The code makes sense, and looks like it will work. The problem is that once methods start being called that are contained in com_content, all the relative URLs in com_content break down and joomla throws an error.

Does anyone know a way to overcome this? A comment from the link above suggests that changing the current working directory to the com_content one before including it will work, but I’m not 100% sure on how to do this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:36:54+00:00Added an answer on June 12, 2026 at 12:36 am

    It’s not possible to change the working directory because its a constant. To work around this issue you could choose not to use ContentModelArticle at all and instead use the table class only:

    $table = JTable::getInstance('Content', 'JTable', array());
    
    $data = array(
        'catid' => 1,
        'title' => 'SOME TITLE',
        'introtext' => 'SOME TEXT',
        'fulltext' => 'SOME TEXT',
        'state' => 1,
    );
    
    // Bind data
    if (!$table->bind($data))
    {
        $this->setError($table->getError());
        return false;
    }
    
    // Check the data.
    if (!$table->check())
    {
        $this->setError($table->getError());
        return false;
    }
    
    // Store the data.
    if (!$table->store())
    {
        $this->setError($table->getError());
        return false;
    }
    

    Note that the code above does not trigger the before/after save events. If that is needed however, it should not be a problem to trigger those events. Also worth noticing is that the field published_up will not be automatically set and the articles within the category will not be reordered.

    To reorder the category:

     $table->reorder('catid = '.(int) $table->catid.' AND state >= 0');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a big Joomla 1.5 Problem. I'll create my own Gallery Component/PlugIn and
I am using Joomla 1.6 along with JCE 2.0.15 I also have created my
Im trying to create some new extensions in joomla. I want to add additional
I have created blank Asp.Net-MVC 3 web application and want to write my own
I have my own asp.net cookie created like this: var authTicket = new FormsAuthenticationTicket(
I have create my own NSOpenGLView class, right now the data that i want
I'd like to create an Excel Add In. But I want it to have
I have created a new android project. I want to have a action bar
I have created my own Attached Property like this: public static class LabelExtension {
I have created my own customized lots of architecture including n-tier layers for different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.